hi.. any body know how to consume rest api with input as file image?
thank you
Hi Meri,
I don't have any samples unfortunately. Note that in the article I mentioned above there should be enough pointers for you to get started, see especially the "Implementation details":
Then I mention my forge component:
"Regardless of the specific solution that makes sense for your project, I created a Forge Component, aptly name Multipart/form-data, that consists of a single eSpace with a number of Public Actions that aid in creating the right content:
So what you need to to do is create a list of parts (using PartAdd or just ListAppend), feed it to MultipartFormDataCreate, use its output parameter BoundaryUsed as input to ContentTypeGet, and use MultipartformatDataCreate.MessageBinary as input to the Binary Parameter of your consumed REST Service, and ContentTypeGet.ContentType as input to the content type Input Parameter (or use it as a Function directly).
Kilian Hekhuis wrote:
Hi Killan,
i have a error
"Failed to load resource: the server responded with a status of 404 (Not Found)"
can u please check my .oap? am i wrong use Multipart/form-data?
thank youu very much
That totally depends on the type of REST API. Does it use multipart/form-data? Or does it expect a base64-encoded binary in a JSON attribute?
hi, killan
it use multipart/form-data..
please help me.. T.T
Meri meri wrote:
I found one document for how to consume rest api (input as file image) in outsystems. Please refer below link
https://success.outsystems.com/Documentation/10/Reference/OutSystems_APIs/outsystems.api.preloader_API#Example
Hope this will helps.
Thanks,
AV
Amit Verma wrote:
hi Amit Verma,
i already try this.
but i get this
can you help me to fix this?
405 error can show when HTTP Method mismatch. Did you set the REST API Method > HTTP Method to POST?
I recently wrote an article about how to consume multipart/form-data REST services. Please read it and if you have any questions left I'd be happy to help.
Thank you for your answer. :)
but, do you have sample to use multipart/form-data plugin with consume Rest API?
i'm sorry, i'm beginner..
A "404" just means that the URL you specified for the REST service is not valid or otherwise not reachable. It has nothing to do with the actual implementation.
hmm.. I see
thank you very much,killan.
I have read your link and tried the plugin you are kindly provided. But somehow I encounter another issue.I have put the parameters as you have instructed as below:
also, the debug value before I send the REST API is as follow:
But I have this following error message saying that the REST API provider didn't receive the binary content I sent ("missing_argument: image"):
can you please show me which one I did wrong?I tried to understand your instruction as best as I could, but there's a possibly that I put the wrong parameter at the wrong place because English is not my first language. Thank you for being very helpful and understanding, Kilian.
One error I can spot is that the "ContentType" of PartAdd for the respective files should be set to the content type of that file, so e.g. "image/jpeg" for a JPG, etc. Not sure if that's where the problem orginates, but I don't think having multiple "multipart/form-data"s in one message is allowed.
This post is very helpful and is what i'm been searching for.
any update on your progress ?
Hi,
The reply from Kilian explains step by step how to do it. And the images on meri reply should give you an idea how to use it.
But it's hard to help more without knowing the details of the services that you are trying to call.
On the images posted by meri the content types used are probably all wrong, since a multipart request should not have other parts with multipart content types.
The documentation for the service should say what the expected types should be.
Regards,João Rosado