Rest API POST Request - Error Converting Value to Int32

I'm new to Retool, so this may be a simple question in the docs somewhere but I have not been able to find an answer.

I have a very simple POST that I'm trying to do that has a very simple JSON body. The body consists of only five values.
Here's a sample payload that works perfectly when run through Postman.
{
"searchTerm": "Bob",
"pageSize": 0,
"offset": 0,
"includeActiveUsers": true,
"includeInactiveUser": true
}

Here's how I have the resource defined:

The problem is that whenever I execute the API call, I receive this error:

{
"type": "RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "|e662989a-4549e6787d996067.",
"errors": {
"$.pageSize": [
"The JSON value could not be converted to System.Int32. Path: $.pageSize | LineNumber: 0 | BytePositionInLine: 34."
]
}
}

I've also tried a raw body but with the same result.

Can anyone help on this?

Thanks!

Hi Jimme - welcome to the fourm!
Hmm, since it's trying to convert the value, maybe try at submit it as a string? "0" as apposed to 0?
Without the documentation of the API you're working with, it's really hard to push you in the right direction.

Hi Jonathan,

Thanks for the response - I appreciate it.

This is very odd, but I have it working now.

What I found by closely inspecting the api request tab was that there were two of each of the properties in the body, except for one. In other words, there were two searchTerm, two pageSize, two offset and two includeActiveUser properties in the body! I have no idea why that was occurring - as you could see from the screen shot there was clearly only one of each defined.

What I did to get it working was simply to delete the resource and create a new one from scratch. Once I did that, the exact same definition worked as expected.

I'd report it as a bug to the Retool team, but I doubt I'd be able to reproduce it.

Cheers!

1 Like