You need to sign in to do that
Don't have an account?
Sridhar Narayansa
HTTP Callout - Adobe - multipart Form Data - not able to identify body parameters
Hello,
We have a requirement to do a HTTP Post to AEM (Adobe Experience Manager).
This service at AEM returns back with the message showing number of parameters and key-value information. (Just an echo for testing).
I am facing a wierd challenge where I posting a file to AEM using HTTP Post multipart form data as in the below code but somehow AEM is not able to identify any parameters being sent within the body.
When we test the same AEM service using Postman it works fine. It replies back with number of parameters and keyvalue pairs that exist in the message body.
I constructed the same multipart message in Salesforce and invoked httppost to AEM, I get null value returned. On taking to AEM team, they mention that message is not being constructed correctly.
So started to sending the Multipart messages to thirdparty clients like postbin, requestbin or beeceptor. They all seem to be fine. I compared this with how postman would send. It looks fine.
In summary:
Postman to AEM - worksfine
Compared Postman message and Salesforce multipart message using requestbin. looks good.
But Saesforce to AEM - doesnt work.
Has anybody experienced similar issue? anybody has integrated with AEM?
I am suspecting that it has something to do with charactersets, but I dont know what could be wrong. I am not sending any special characters.
Any suggestions?
We have a requirement to do a HTTP Post to AEM (Adobe Experience Manager).
This service at AEM returns back with the message showing number of parameters and key-value information. (Just an echo for testing).
I am facing a wierd challenge where I posting a file to AEM using HTTP Post multipart form data as in the below code but somehow AEM is not able to identify any parameters being sent within the body.
When we test the same AEM service using Postman it works fine. It replies back with number of parameters and keyvalue pairs that exist in the message body.
I constructed the same multipart message in Salesforce and invoked httppost to AEM, I get null value returned. On taking to AEM team, they mention that message is not being constructed correctly.
So started to sending the Multipart messages to thirdparty clients like postbin, requestbin or beeceptor. They all seem to be fine. I compared this with how postman would send. It looks fine.
In summary:
Postman to AEM - worksfine
Compared Postman message and Salesforce multipart message using requestbin. looks good.
But Saesforce to AEM - doesnt work.
Has anybody experienced similar issue? anybody has integrated with AEM?
I am suspecting that it has something to do with charactersets, but I dont know what could be wrong. I am not sending any special characters.
Any suggestions?
public class ABCService_v2 { public static void addJobApplication() { // Set body String boundary = '----------------------------' + String.valueOf(DateTime.now().getTime()); String body = '--' + boundary + '\r\n'; body += 'Content-Disposition: form-data; name="buildingId"\r\n\n'; body += 'id_building\r\n'; body += '--' + boundary + '\r\n'; body += 'Content-Disposition: form-data; name="buildingName"\r\n\n'; body += 'Fashion101\r\n'; body += '--' + boundary + '\r\n'; body += 'Content-Disposition: form-data; name="suiteName"\r\n\n'; body += 'Suite-100\r\n'; body += '--' + boundary + '--'; // Instantiate a new HTTP request HttpRequest req = new HttpRequest(); // Set method and endpoint //req.setEndpoint('http://https://requestbin.fullcontact.com/1hlgohv1'); req.setEndpoint('https://someservicedev-dev.someservice.com/bin/io/floorplan'); req.setMethod('POST'); // Specify the required user name and password to access the endpoint // As well as the header and header information String username = 'jdoe'; String password = 'jdoe123'; // Set headers req.setHeader('Content-Type', 'multipart/form-data; boundary=' + boundary); req.setHeader('Content-Length', String.valueof(body.length())); //req.setHeader('Accept-Charset', 'utf-8, iso-8859-1;q=0.5'); req.setHeader('Accept-Charset', '*'); req.setHeader('Accept-Encoding', 'gzip, deflate'); req.setHeader('Connection', 'close'); req.setHeader('Accept','*/*'); Blob headerValue = Blob.valueOf(username + ':' + password); String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader); //Set Body req.setBody(body); // Send HTTP request and get HTTP response Http http = new Http(); HttpResponse res = http.send(req); system.debug('==============res: ' + res.getBody()); } }
Did you got solution for above? I am facing same issue.
Regards,
Gaurav
We abondoned the approach of using Apex code to upload images for two main reasons.
1. Authentcaton on AEM needed to be of the user. So using a generic service account was not a good idea for aurdit purpose
2. Using this method would result in Heapsize limit. Apex will not be able to handle images of large size. Max was around 3MP and when converted to Base64 it would result in more than 5MP exceeding governor limits.
Here is the recommended solution that we implemented.
1. Have AEM expose an Iframe with Single-Sign-On
2. Call an a Ifram URL from Salesforce by passing some Key-value-pars in the URL
3. Let AEM process the URL for unique key-value-pairs, let AEM sign in the user and let AEM do the heavy lifting and stay generic image upload.
This change in design greatly simplified the architecture/design.
I hope this helped.
Thanks,
Sridhar