Rest API "form-data" as Body Input

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Frank2
Posts: 21
Joined: Tue Nov 17, 2020 10:33 pm

Rest API "form-data" as Body Input

Post by Frank2 »

Hi,

I am trying to implement a POST rest service in Aware. The API call works in Postman, but the data is passed as "form-data" instead of the raw body json format that I am used to use.(The option selected in Postman) How do I implement this in Aware as it won't work when I take the username and password from an object that is in context?

Thanks
Francois
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Rest API "form-data" as Body Input

Post by Jaymer »

Sorry, do not understand
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Frank2
Posts: 21
Joined: Tue Nov 17, 2020 10:33 pm

Re: Rest API "form-data" as Body Input

Post by Frank2 »

Hi Jaymer,

Sorry for the confusion. Please have a look at the 2 attachments. Both screenshots from Postman.

In Screenshot1 you will see that the Body data is sent through as form data(x-www-form-urlencoded),which is the correct way to do it for this specific API.

In Screenshot2 you will see that the Body data is sent through in raw JSON format. I have created all my previous POST Rest services in the same manner in Aware, works great because the Input Parm object is in context and in JSON format.

What I want to know. How do I implement the POST with parameters sent as form data(as in Postman-because the API gives me a return,code 200).
If I implement it in the same way as above, taking the Parm Object in Context as input, I get an error, that is in Aware.. Should this rather be used as a string(see screenshot3). None of it is working, or should I pass a HEADER with it?
Attachments
Screenshot3.PNG
Screenshot3.PNG (30.99 KiB) Viewed 3915 times
Screenshot2.PNG
Screenshot2.PNG (10.17 KiB) Viewed 3915 times
Screenshot1.PNG
Screenshot1.PNG (28.68 KiB) Viewed 3915 times
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Rest API "form-data" as Body Input

Post by Jaymer »

Postman shows the payload,
and I think doing this will send the same JSON string:
rest1.png
rest1.png (150.64 KiB) Viewed 3909 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Frank2
Posts: 21
Joined: Tue Nov 17, 2020 10:33 pm

Re: Rest API "form-data" as Body Input

Post by Frank2 »

Hi Jaymer,

Thank you for the reply.

Still no joy. I have attached the API error and also the API Curl command provided by the API company.
And the error attached is the one I get when I do it like you showed in your example above.

I have included the necessary HEADERS in Aware.

According to me it should work.

Kind regards,
Francois
Attachments
CurlCommand.PNG
CurlCommand.PNG (44.23 KiB) Viewed 3899 times
APIError.PNG
APIError.PNG (13.05 KiB) Viewed 3899 times
Frank2
Posts: 21
Joined: Tue Nov 17, 2020 10:33 pm

Re: Rest API "form-data" as Body Input

Post by Frank2 »

Hi Aware_Support,

Any thoughts on this porblem?

Kind regards,
Francois
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Rest API "form-data" as Body Input

Post by Jaymer »

If this is what curl is sending, then why aren't you doing the same thing:

In the "use this string" field:
username=<<LoggedInRegularUser.LoginName>>&password=<<LoggedInRegularUser.APIPassword>>

Screen Shot 2023-02-20 at 11.26.15 AM.png
Screen Shot 2023-02-20 at 11.26.15 AM.png (90.55 KiB) Viewed 3870 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Rest API "form-data" as Body Input

Post by aware_support »

If you want us to investigate please pay for a support ticket (we will send you the invoice) and attach a small BSV that demonstrates the issue along with the description of how to reproduce the problem in this BSV
Aware IM Support Team
Frank2
Posts: 21
Joined: Tue Nov 17, 2020 10:33 pm

Re: Rest API "form-data" as Body Input

Post by Frank2 »

Hi Jaymer,

Thank you very much, working now. Just wasn't too sure how Aware wants me to send the String through. Also, I had to change the Content type to Text/XML and not JSON.

Thanks for the help.

Kind regards,
Francois
Post Reply