Hello, I'm try consume a customer API.
I am trying to get token.
In postman and service studio test API, works fine! Getting token, but in runtime is not working. GET Response Error Code 422 Unprocessable Entity.
The Screenshot for the test API.
Input and output parametersRequest send in Body
Request Runtime
HTTP Error
Please, ideas to resolve this
Sending test environment OML
Thank you in advance
Hi Marcelo,
I have made some changes to your OML. I hope this helps you to implement further.
Hi,
I am also facing same issue, I want to pass the user name and password through body while consuming POST method API with request format set to "Form URL Encoded" .
I am not able to do it in OutSystems, but in postman it is working.
I got the 500 internal server error
Hello @Marcelo,
here you have to do to pass this request on OnBeforeRequest , I am sharing some snapshots that might help
Click On the Rest Api Got to Advance Options there Go to On Before Request on that
Drag and drop a assign and on assign On your request pass your request
Pass Your request here, you can use it after that it will work
You can also refer to this - https://www.outsystems.com/forums/discussion/36156/guide-consume-rest-api-with-form-url-encoded-request/
Hope this helps
Thanks
Hi Tousif Khan
Thank you, for the quick answer.
I put it according to your comment and the error 422 still persists.Request.RequestText = "grant_type=client_credentials" + "&username=" + username + "&password=" + password + "&client_id=" + ClientId
Hello
there was some issue with your request actually your request was taking input with double quotes
"", so using some logic of string literals , I have fixed it now you can check it is working
Remove preceeding and ending double quotes in your request.
Request body in Outsystems API Editor is not an expression.
Thank you all for the helpThe problem was the quotes on request
Solved
Yes your request is inclosed with double quotes, thats why we are getting error,
and so we have to provide extra "" to inclose it again
best part problem is solved.
cheers