TestProject Forum

Invalid Restful API Header

I’m trying to use the following header in a Restful API call “Content-Type: application/x-www-form-urlencoded”, but I keep getting the error message:

“java.util.concurrent.ExecutionException: io.testproject.java.sdk.v2.exceptions.FailureException: The ‘header: ‘Content-Type: application/x-www-form-urlencoded’’ parameter is invalid
Caused by io.testproject.java.sdk.v2.exceptions.FailureException: The ‘header: ‘Content-Type: application/x-www-form-urlencoded’’ parameter is invalid”

Why would I be getting this message? As far as I’m aware, this header should be valid. The API call works on the website and through Postman, and I can find examples of that kind of header online. Is the type of header just unsupported by TestProject at this time?

Hello @jbauer,

Please notice that you didn’t set the header in the right format, headers should be in this format:
header=value, but you set it as header:value,
image

Thanks, that helped a ton! Are there similar syntax requirements for the Body section as well?

So, looks like the body has to formatted to be x=y. If you have multiple statements in your body, they are separated by ‘&’ symbols. This means that a body request might look like “grant_type=password&client_id=lotofrandomlettersandnumbershere12345&username=jbauer&password=shhhsecret&scope=morerandomlettersandnumbers offline_access”, but without the quotation marks.