cancel
Showing results for 
Search instead for 
Did you mean: 

REST PUT - Where to put Body Message

aemery
New Contributor

Hello,

I have a REST service that first requires a PUT with a JSON body with the username/password in the body, and it will return a key. I can get it to work in SoapUI and Postname, but am unable to figure out how to make it work in Snaplogic.

I constructed what was used as the Body in Postman in the JSON Generator snap -

[
{
“username”: “someuser”,
“password”: “somepassword”
}
]

However how do I call that from the REST Put snap?

Thanks in advance for any assistance.

5 REPLIES 5

j_angelevski
Contributor III

Hi @aemery ,

You can put any JSON you want in the Rest PUT snap in the HTTP Entity setting.
image

aemery
New Contributor

Ok, so I put this JSON (user/pass redacted) in the HTTP Entity field -
{“username”: “USER”, “password”:“PASS”}

image

This is the same JSON string that works when I use Postman or SoapUI.

And I got this error -
Provided JSON is incorrect

Resolution:

Please ensure that the provided JSON is correct

Reason:

Unexpected character (‘C’ (code 67)): Expected space separating root-level values at [Source: (String)“1CE2D9161EF94E548076FAD3BCA6A4F7”; line: 1, column: 3]

j_angelevski
Contributor III

You need to enable the expression field if you want to use json inside the http entity setting. ( Just click on the = sign ). If you don’t enable the expression, then everything inside this property will evaluate to a string, which is why the error is telling you that you provided incorrect JSON.

ok, that got me further, however the service returns a text/plain object so now Snaplogic gives an error saying it is expecting JSON. I set the following so that it would accept any object -

Accept = */*

Edit: the asteriks were removed from the post