34
Views
13
Comments
Consume PUT method REST API with Multipart/form-data as Request Format.
Application Type
Reactive
Service Studio Version
11.54.52 (Build 63199)
Platform Version
11.29.0 (Build 43552)

Hey everyone, 

I need to consume a Rest API with PUT method and having Request Format as Multipart/form-data. Since Outsystems does not support PUT with Multipart/form-data, how will I be able to consume the API without modifying exposed API itself.

Error Says- 

  1. Invalid Request Format
    'PutTestAPI' method has an invalid Request Format property. Either change this property, modify the body input Data Type or add a new body input.
UserImage.jpg
Magnus

Hello, perhaps this forge component can help you: https://www.outsystems.com/forge/component-overview/4026/multipart-form-data-o11

UserImage.jpg
Saurabh Dhoble

Hello @Magnus, Thanks for you reply.

Forge component- multipart-form-data-o11 changes the Request Format of consumed API to Binary, but I need Multipart/form-data. I tried this solution but that would require some modification in exposed API which unfortunately cannot be done. Any other solution would be appreciated. Thanks

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Saurabh,

I think you are mistaken. There is no "binary" Request Format. The OutSystems multipart/form-data functionality is based on the functionality from the Forge asset, and it works largely the same. It is true that you cannot use PUT with the native functionality, unfortunately, but the Forge asset should work just fine.

If you are having trouble getting it to work, I'd ask you to post in the Forge asset's subforum.

UserImage.jpg
anis hidouri

I am experiencing the same issue. I am using `MultipartFormDataCreate` to prepare a request for uploading a file via a POST API request. While it works for POST requests, it does not work for PUT requests.


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Anis,

Just to make sure: are you using the platform-native functionality, or are you using the Forge asset?

UserImage.jpg
anis hidouri

Thanks for your reply , i'am using the forge asset 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Ok, then it's simple: the Forge asset does not in any way need POST or PUT, it just creates the body of the request. If it doesn't work for PUT requests, the data you sent is wrong. Do you get a specific error message from the API you are calling?

UserImage.jpg
anis hidouri

I do the same thing as Post, which works. I tested with Postman the API works fine, but the response: File is required . It's like the file is missing when I try to do the put.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

You will agree with me that if the code path before deciding to call either PUT or POST is the same, and from your image it seems the are, it's impossible for the PUT to have a different payload than POST.

UserImage.jpg
anis hidouri

it's the same payload for both , it's just the request method that change! 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Well, then it must be that the API expects a different content when using the PUT than when using the POST.

UserImage.jpg
anis hidouri
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

That is indeed very weird. Have you also checked all the parameters of the POST and PUT call, any On Before Request, etc. to see if both methods are completely identical (except for the POST/PUT of course)?

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