0

So I receive plain text which contains image coded in base64 format. String I receive from request IMG :

enter image description here

Example :

iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==

I need to post this string to https://api.imgbb.com/1/upload?key={key} I am able to send it manually in by using ARC ARC Sending request IMG :

enter image description here

I need to send this plain string using Mulesoft I tryed many ways : my post request :

enter image description here

<flow name="reciveProfilePicture" doc:id="a1b3f198-c5e3-4e8d-b309-f69e9e0552f4">

</ee:set-payload>
            </ee:message>
</ee:transform>

        <http:request method="POST" doc:name="Request" doc:id="dc91be5d-bbfc-4ce3-834c-a1b93569add5" url="https://api.imgbb.com/1/upload?key=c7756bd8c7786364112046dd9694d5fd" responseTimeout="10000">
            <http:body ><![CDATA[#[image : payload]]]></http:body>
        </http:request>
        <ee:transform doc:name="Transform Message" doc:id="e831fa15-cc87-495d-aeaf-03b761ba0ea8" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
    </flow>

Error: "HTTP POST on resource 'https://api.imgbb.com/1/upload?key={key}' failed: bad request (400)."

Amira Bedhiafi
  • 8,088
  • 6
  • 24
  • 60
  • [1]: https://i.stack.imgur.com/wiZm5.png String I receive from request [2]: https://i.stack.imgur.com/shZxt.png ARC Sending request [3]: https://i.stack.imgur.com/9olFB.png my post request – Arvids Kramins Aug 09 '19 at 07:45

1 Answers1

0

It looks like the data needs to be send into an HTTP attachment (multipart/form-data). See an example of how to do that in the Mule 4 example at https://docs.mulesoft.com/mule-runtime/4.1/migration-connectors-http#http_multipart

aled
  • 21,330
  • 3
  • 27
  • 34