Expand my Community achievements bar.

SOLVED

Do ACC API support multipart/form-data creation?

Avatar

Level 2

Hello Expert,

I'm developing the javascript to call the Web-service. However, they require the media-type as 'multipart/form-data'.

I've checked this link about ACC API -> https://experienceleague.adobe.com/developer/campaign-api/api/p-8.html

But it's look like, ACC don't have any class that support to create multipart/form-data

I'm not sure that Adobe Campaign Classic v7 can form this type of data? Or can we import the form-data library into ACC -> How to?

Please help.

Thank you.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

I'm not sure I'm getting what you're trying to achieve. Do you want to call a remote webservice with ACC and that remote webservice requires multipart/form-data?

In Campaign you can use the HttpClientRequest class to construct your http call (including the Content-Type header as multipart/form-data) and send it to the webservice: https://experienceleague.adobe.com/developer/campaign-api/api/c-HttpClientRequest.html?hl=httpclient... 

Best regards, Tobias

View solution in original post

4 Replies

Avatar

Correct answer by
Employee Advisor

Hi,

I'm not sure I'm getting what you're trying to achieve. Do you want to call a remote webservice with ACC and that remote webservice requires multipart/form-data?

In Campaign you can use the HttpClientRequest class to construct your http call (including the Content-Type header as multipart/form-data) and send it to the webservice: https://experienceleague.adobe.com/developer/campaign-api/api/c-HttpClientRequest.html?hl=httpclient... 

Best regards, Tobias

Avatar

Level 2

Hi Tobias,

Thanks for the response.

Yes, I'm trying to use ACC to call a remote webservice which required multipart/form-data.

And yes, I can use HttpClientRequest with header-type as multipart/form-data.

 

However, I'm stuck at attach the upload file.

The webservice require to upload the file as string(binary) which I have found many posts that using FileReader.readAsBinaryString() but look like that Adobe did not support this class.

 

So, I'm not sure that do we have any other choices that I can do?

PS: If you have an example, please put it in the post.

Thank you

Avatar

Level 2

Hi Tobias,

I'm trying to do as your said by use HttpClientRequest with header-type as multipart/form-data.

And create a form-data format by following this link

https://stackoverflow.com/questions/47080869/how-to-manually-create-multipart-form-data

Remark: Unfortunately, this link is not verify as accept solution but I think it should be fine.

 

I try to call again via HttpClientRequest but the destination throw 422 'Unprocessable Entity' back.

May be this way we need to change from HttpClientRequest to XMLHttpRequest.

However, XMLHttpRequest is not available in ACC as well.

 

Do you have any workaround for this?

Thank you.

Avatar

Employee Advisor

Hi,

not a 100% sure, but it might not be possible at all using Campaign's Javascript engine. Are we talking about an on premise installation of Campaign? If yes, you could try to utilize curl 

curl -v -F key1=value1 -F upload=@localfilename URL

This would offload the task to the os level.

Best regards, Tobias