Getting 204 with Smartsheets put request on Postman but 400 in .NET Core Web API
I am testing the same data in postman verses a .NET Core Web API project, however, one returns fine when content is being updated and another (.NET Core) returns 400. Any ideas on why this may be? It's the same data structures, and even same data.
Answers
-
I'm unable to identify what the cause may be based on this information. Would you be able to post the exact query you're making (removing any sensitive data), what language you're using, and a screen capture of the exact error?
Thanks,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Sure.
Here is my .NET Core (C#) wrapper API.
[HttpPut("{sheetId}/rows")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> UpdateSmartSheetRow(long sheetId,
[FromBody] UpdateSheetRow updateObj)
{
string Url = GetSmartSheetUrl();
if (Url == null) return BadRequest();
string BearerToken = GetSmartSheetApiToken();
if (BearerToken == null) return BadRequest();
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", BearerToken);
httpClient.DefaultRequestHeaders
.Accept
.Add(new MediaTypeWithQualityHeaderValue("application/json"));
try
{
HttpResponseMessage response =
await httpClient.PutAsJsonAsync(Url + sheetId + "/rows/", updateObj);
if (response.IsSuccessStatusCode)
{
return Ok(await response.Content.ReadAsAsync<UpdateSheetRowResponse>());
}
return StatusCode(400, response.ReasonPhrase);
}
catch (Exception ex)
{
return StatusCode(500, ex.Message);
}
}
-
Thank you for this additional information!
I blocked out your Bearer token from one image, and I would suggest deleting your current access token and generating a new one since it was displayed for a bit in this public forum.
I'm still unable to identify what's causing the error; at this point I would suggest reaching out to Smartsheet Support with the same screen captures and data that you have posted here, but also include what JSON response looks like in the 400 error. They'll be able to troubleshoot this with you in a private channel.
Thanks again,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.5K Get Help
- 424 Global Discussions
- 136 Industry Talk
- 465 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 145 Just for fun
- 62 Community Job Board
- 465 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 301 Events
- 39 Webinars
- 7.3K Forum Archives