267
Views
9
Comments
Solved
Consume Rest API x-www-form-urlencoded - Token Authorization - Getting Error 422
Application Type
Reactive, Service

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 parameters
Request send in Body 



Request Runtime


HTTP Error 


Please, ideas to resolve this

Sending test environment OML

Thank you in advance

2022-07-24 08-50-37
Gokula Kannan P
Solution

Hi Marcelo,

I have made some changes to your OML. I hope this helps you to implement further.

TestPostToken.oml
UserImage.jpg
Harbor V

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.

UserImage.jpg
Harbor V

I got the 500 internal server error


2023-10-21 19-42-11
Tousif Khan
Champion

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

2020-02-17 18-58-11
Marcelo Leao

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


TestPostToken.oml
2023-10-21 19-42-11
Tousif Khan
Champion

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

TestPostTokenFixed.oml
2022-07-24 08-50-37
Gokula Kannan P
Solution

Hi Marcelo,

I have made some changes to your OML. I hope this helps you to implement further.

TestPostToken.oml
UserImage.jpg
Harbor V

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.

UserImage.jpg
Harbor V

I got the 500 internal server error


2024-03-25 06-19-08
Harlin Setiadarma

Remove preceeding and ending double quotes in your request.

Request body in Outsystems API Editor is not an expression. 

2020-02-17 18-58-11
Marcelo Leao

Thank you all for the help
The problem was the quotes on request


Solved

2023-10-21 19-42-11
Tousif Khan
Champion

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.