08-19-2021 07:01 AM
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.
08-19-2021 07:32 AM
Hi @aemery ,
You can put any JSON you want in the Rest PUT snap in the HTTP Entity setting.
08-19-2021 09:10 AM
Ok, so I put this JSON (user/pass redacted) in the HTTP Entity field -
{“username”: “USER”, “password”:“PASS”}
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]
08-19-2021 09:44 AM
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.
08-19-2021 10:17 AM
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