hi guys, this time i bring you an API. As you can see i can use it in Postman, but when i try to consume it on OS i m always getting the same error
i get bad request and display that error message
I must be doing something wrong, can anyone help me out to config them? I trust if i can do this one i will be able to do the rest of them. I m consuming APIs but they have diferent config in postman, so i might ask for them also
Yes. This makes sense now. It is not a url encoded form but a multipart request. First you have to know that you cannot test multipart requests in the wizard. You have to build your consume action by
Select single method from the consume rest api screen
Select post as method and enter the Url, then click finish
In the properties of resulting consume action select "Multipart/form-data" in the Request Format.
Add two input parameters to the consume action (Username and Password) both of type text. Make sure to set Log Redaction to true for the password :-)
Construct the Result structure manually and add it as Result output parameter, then select Json as response format. See attached OML (this one has text/plain as result as i do not know exactly your response structure). This should do it.
Hi João Pedro Espinheira,
You need to put the value into the text parameters as they are saying username and password is require into message window. I will suggest you to watch this video and you wI'll have proper idea about consuming api in outsystems
https://youtu.be/gNyWIeJYfG0?si=VXNlR6xKNgRkVJV_
Hope this helps
Prince
Taking your screenshot from Postman you have to send as application/x-www-form-urlencoded (see form-data in Postman). In your OutSystems screenshot however you send a json document which does not match
To send as form-data your request must look like this
username=<YourUsername>&password=<YourPassword>
The request type must be set to form url encoded
Best
Stefan
hi Stefan, your answer works, but now i have diferent problem. In postman i do receive answer but in OS i get this
the password and username are correct as they work on postman. If i change those to incorrect ones says they are invalid. Am I missing something?
might be that the parameters are case sensitive. have you checked if
Username=<username>&Password=<password> works?
or.. do you have any specific headers that are sent with the request?
Nope, everything i used is in those prints. Its not case sensitive, and i know that they are good as they work postman, and even in OS i do have an answer, just not the right one. it returns the code 405. Does that mean that the API doesnt work on Outsystems?
Hi. No, i havent Seen any api before that ist Not working with outsystems. Try ro explictly add the following Headers in the requests
Content-Type application/x-www-form-urlencoded
Accept application/json
Is there a Chance i could try the endpoint?
Can you also add a Screenshot of the request you sent that produced the 405?
what i did was this, no authentication, no headers. Only that request, and i know that the username and password are correct since they work on postman
this is your sugestion (i think is not it since nothing changed and OS already assumed the urlencoded with that resquest)
and if i do like postman
multipart/form-data; boundary=<calculated when request is sent> in order to you to know what is writen on postman. Hope that this can help you to help me ahah
Hi stefan. Thats it!!!!
I had to change my response structure and did what u said and it works now! Thank you a lot!
i think i might have other problems with diferent API's but i will do a new forum discussion