on 04-01-2019 10:31 AM
Hello Experts,
This requirement is regards to IDOC to HTTP_AAE(.csv multiform data) scenario.
While delivering the message from SAP ECC to Http server via EAI SAP PI 7.5 facing below error.
HttpAdapterException: STATUS_CODE_NOT_OK- 500 Internal Server Error MP: exception caught with cause com.sap.aii.adapter.http.api.HttpAdapterException: STATUS_CODE_NOT_OK- 500 Internal Server Error
Exception caught by adapter framework: STATUS_CODE_NOT_OK- 500 Internal Server Error
Transmitting the message to endpoint <local> using connection AFW failed, due to: com.sap.aii.adapter.http.api.HttpAdapterException: STATUS_CODE_NOT_OK- 500 Internal Server Error
Kindly provide your valuable inputs. Many Thanks..!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
In HTTP_AAE receiver channel under Advanced Tab set the Additional parameters as below:
preferredContentTypeHeader true
Also under General Tab in request details tick the 'Set form' and name the main payload parameter name as 'file' and tick the 'Set Multipart' and 'Keep Attachments'.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
how was this resolved?
can you share your ID module and receiver channel configuration?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Narendra,
The UDF code I have shared earlier can be used in the java mapping.
You can create the java mapping to create multipart data. did you try the trace HTTP option?
Thanks
Sugata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sugata,
Now message is delivered successfully without using any java mapping. Only ID Module configuration and setting up ASMA in ESR.
But filename is not reading. It is getting delivered as MainDocument and not going as AIL_INV_IDOCcreatedDate_IDOCcreatedTime
HTTP_CLIENT : 5161 REQUEST:
------=_Part_546_1040778488.1554801212614
Content-Type: multipart/form-data;
Content-ID: <payload-bf322c1c5aa711e9cdd20000001e93ee@sap.com>
Content-Description: MainDocument
Content-Disposition: form-data; name="file"; filename="MainDocument" SKUId,EANNumber,Warehouse,Quantity,UOM,Cost,Entity,TransactionType
USPOLI781,987980007333,1200,1,PC,98,ALBL,NA
------=_Part_546_1040778488.1554801212614--
Path:
ALBLMT/SOH/local/AIL_MainDocument
headers:
DynamicConfiguration conf2 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System", "HeaderFieldOne"); conf2.put(key1,fileName); return "";
Hello Narendra,
At this point, I am clueless :-). Because , I tried the same approach and it worked for me.
According to your API call to S3- I can see from the below raw HTTP data -
POST
Host:
Authorization:
Cache-Control: no-cache
Postman-Token: 40d10c88-3f4f-387d-6dca-a87582be7ae6
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------
WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="AIL_INV_20180111_150116.csv"
Content-Type: application/vnd.ms-excel
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=""
------WebKitFormBoundary7MA4YWxkTrZu0gW--
you have two parameters at your target HTTP / web form - file and name. and it worked even though you did not provide the key/value pair for name. Which means it is not mandatory.
could you please try tracing the HTTP log for this interface? you can trace the HTTP error and download the log from NWA. Please set up the same using the SAP note -
2157425 - New Feature: Client side HTTP Tracing for HTTP_AAE adapter
Please configure and run the scenario and collect the trace. Let me know the log details.
Thanks
Sugata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sugata,
Please refer the below link, is it achievable in PI 7.5 ? wherein content /mime types are generated via Java mapping
https://blogs.sap.com/2014/09/12/html-form-upload-using-http-plain-adapter-with-java-mapping/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also check if the Network is open from your PI system to their HTTP system, or if you need to install any certs in PI.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Narendra,
As I have mentioned earlier you have to create only 1 operation mapping , in that 1step graphical mapping will be IDoc to XML mapping and 2nd step graphical mapping will be to create attachment using the UDF and assign some value to the target field.
could you please also let us know the details of target HTTP web page ? how the HTTP form looks like? a screenshot will do. I have tested the same way I have descried earlier and it worked.
Thanks
Sugata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Narendra,
As you have to send the actual data as a file, you have to convert the XML into CSV and create an attachment in the mapping itself. As your scenario is an IDoc to HTTP. I think it is a simple Async scenario, if you are expecting a response back from the target HTTP server then you have to use the request response bean and replace interface configurations in your receiver channel. As of now I am considering this as a Async scenario where you have to send the payload as a csv file and a text value as the HTTP body.
Please try the following steps-
1. Create two target data types and message types - 1st data and message type will be your actual payload structure- Records. The 2nd data type and message type will be a single field.
Something like this -
2. Create two message Mappings- 1st mapping is the actual mapping for IDoc to 1st target structure, you already have this one. the 2nd mapping is the one where you have to create the CSV from the XML output generated from the 1st mapping and assign the csv file as an attachment to the XI message.In this mapping your source structure will the 1st message type (with Record nodes) and target structure will be the 2nd message type with single field you have created.
in the 2nd step mapping you have to create an UDF to convert the XML to csv and create an attachment. please adjust the code below with your 1st structure's field names and use it - in this UDF you have to pass all the fields as source-
AbstractTrace trace = container.getTrace();
String header = "Name,Id,Email"; // field names from your first structure
String content = header + "\n";
String mimeType= "application/vnd.ms-excel;charset="+ "\"" + "uft-8" + "\"";
String filename = "Attachment.csv";// you can dynamically set this
for(int i =0; i< Name.length; i++)
{
// adjust the below line with your field names from first structure
content = content + Name[i] +"," +Id[i] + ","+ Email[i] + "\n";
}
trace.addInfo(content);
//Create attachment with CSV data
try
{
GlobalContainer globalContainer = container.getGlobalContainer();
OutputAttachments outputAttachments = globalContainer.getOutputAttachments();
Attachment attachments = outputAttachments.create(filename, mimeType, content.getBytes());
outputAttachments.setAttachment(attachments);
result.addValue("filePath"); // you can dynamically set this
} catch (Exception e)
{
result.addValue(e.toString());
}
3. create the Operation mapping with these 2 message mappings - 1st mmaping will be actual transformation and 2nd mapping will be creating the attachment and CSV file. In your operation mapping the target service interface should have the message type of single field.
4. go to integration directory and setup your receiver HTTP_AAE channel as below -
Here, note is the target HTTP form field name, you can replace as per your scenario-
5. That's all, you do not have to use message transformation bean in the receiver HTTP adapter.
6. In the UDF you can see, I have given a static filename and a constant value to the payload parameter. You can dynamically set the file name and HTTP body (payload value) in your first mapping . for this , you can add two extra field in your first structure and store the file name and payload value there- which can be passed into the second mapping UDF.
7. Once this is setup you can see the message monitoring - the payload will be the value you specify as http payload body and there will be the attachment-
Hope this will help. Please let me know if you are able to process messages succefully.
Thanks
Sugata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sugata,
I had tried the same way. Still facing the same issue.
4/4/2019 03:25:42.675 PMInformationMP: processing local module localejbs/sap.com/com.sap.aii.adapter.http/HttpAdapterBean4/4/2019 03:25:43.139 PMErrorError in processing caused by: com.sap.aii.adapter.http.api.HttpAdapterException: STATUS_CODE_NOT_OK- 500 Internal Server Error4/4/2019 03:25:43.139 PMErrorMP: exception caught with cause com.sap.aii.adapter.http.api.HttpAdapterException: STATUS_CODE_NOT_OK- 500 Internal Server ErrorHi Narenda,
Error code 500 indicates a problem on the HTTP server side so you will need to find more information about the problem on that end. Once you get more detail surrounding the root cause then you can take the appropriate action to make the necessary changes in your integration scenario.
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Narendra,
As per your screenshot, I think you are trying to send the payload after the content conversion - the csv file as an attachment and the file path as HTTP body, is this correct?
did you swapped the payload to set the csv file as attachment? I can see you have only used the MessageTransformation Bean to convert the XML from mapping.
And I think, to set the attachment name dynamically you need some adapter module after the conversion is done.
Thanks
Sugata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Narendra,
Please check the following points -
1. how do you want to send the data to the receiver ? if it is only a simple POST then you do not have to use the setForm or multipart.
2. if you are sending data to target as a form based data then the main payload should be defined in the receiver channel according to the form input for the target HTML form. The payload will be passed to that input parameter. And in this case the content type should be application/x-www-form-urlencoded. In this case the entire payload will be mapped to the target HTML form input.
3. In your UDF, the Adapter attribute namespace is using for File and REST, for HTTP adapter, it is
http://sap.com/xi/XI/System
And the paramters are URLParamOne,URLParamTwo etc. until PramaSix.
Thanks
Sugata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sugata,
Regards point no 1, this is not a simple POST method and it works only with multi form-data content-type. Please find below snapshot:
regards point no 2, it is not working with content type 'application/x-www-form-urlencoded' and please find the API correct code snippets below:
regards point no 3, the attribute namespace is corrected in ASMA UDF and resent the message but though facing same error i.e.
DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "filename"); String filename=conf1.get(key1); DynamicConfiguration conf2 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System", "filename"); filename = "AIL_INV_" + CREDAT + "_" + CRETIM + ".csv"; conf2.put(key2,filename); return filename;
Error:
Transmitting the message to endpoint <local> using connection AFW failed, due to: com.sap.aii.adapter.http.api.HttpAdapterException: STATUS_CODE_NOT_OK- 500 Internal Server Error
There is no URL parameters and API has only body parameters.
key - file
value - AIL_INV_20190402_105412.csv
file upload in form-data content-type
User | Count |
---|---|
76 | |
10 | |
8 | |
8 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.