A vendor's documentation has a parameter has an array of bytes in place of a file. Is there a way to do this in an IPA?
Inside of a file? Web Call?
One of the vendors would like a call to upload a file. Their documentation has:
This endpoint requires a Http POST, with the data (fileName (String) , fileDescription (String), fileData (byte[]), productNumberColumnNums (List<Integer>), supplyChainColumnNums (List<Integer>), descriptionColumnNums (List<Integer>), facilityInventoryIDs (List<Integer>), domainIDs (List<Integer>) .
The problem I have is the fileData. The vendor gave a sample Java program which displays a menu. Essentially, it tests to see that the call can be done, requests the file name and convert it to a byte array, requests the relative column number in the file for the 3 fields (product number, supply chain, and description), requests the facility ID (only 1 value), requests the domain IDs, and upload the file given all of the data manually entered. I have no issue with the other data except for the fileData.
Based on their requirements, I thought I would be doing a web run with a post method, but the fileData puzzles me. Even if I figured out the fileData, I was not sure how big this call could be.
Our version is 10.1.1.63. We have not upgraded Landmark in a year.
The only way you can do this in IPA is possibly with this.1. Read your "file data" into a flow2. Create a string in your start node called "data"3. Set the string variable data= file_outputData to make sure its a string.4. Use an Assign node with javascript.var bytes = [];var char;
for (var i=0; i<data.length;i++) { char = data.charCodeAt(i); bytes.push((char & 0xFF00) >> 8); bytes.push(char & 0xFF);}There are a few examples like the above found on StackOverflow; this is not my javascript. But I ran in on my v11.0.34 test system and it did not fail and did generate a byte array. But using javascript for this might not be the greatest. Depending on the javascript engine being used you can get different results; and if there are special characters in the file you are reading its not going to work The above code snippet comes from:https://stackoverflow.com/questions/12332002/how-to-store-a-byte-array-in-javascriptIt is a fairly good read on the topic and worth a review as it may help you with this issue.
Is it possible to send Byte Array in a Web Run POST request?
My Byte Arrays seem to be getting interpolated as strings, e.g. [B@d3fecf and the response indicates it thinks that is an incomplete array or invalid JSON key value pair (e.g "Expected a ',' or ']' at character 120)