09-01-23 12:20 PM
Hi. Im having big problems getting a Web API to take data from af collection and sending a message.
My Template is like this.
{
"MessageBody": {
"LegalEntityId": "[LegalEntityID]",
"SourceSystem": "[SourceSystem]",
"JournalLines": [
{
"SourceSystemId": "[JournalLines_new.SourceSystemId]",
"Date": "[JournalLines_new.Date]",
"ProjectId": "[JournalLines_new.ProjectId]",
"EmplId": "[JournalLines_new.EmplId]",
"ICWarehouse": "[JournalLines_new.ICWarehouse]",
"ICLocation": "[JournalLines_new.ICLocation]",
"Qty": [JournalLines_new.Qty],
"ItemId": "[JournalLines_new.ItemId]",
"WorkorderId": "[JournalLines_new.WorkorderId]"
}
]
}
}
In the object i have two dataitems called "LegalEntityID", and "SourceSystem", and a Collection called "JournalLines_new"
It takes the LegalEntityID, and SourceSystem correctly, but the collection beings passed to the object that handles the API call is being ignored.
I have tried the Utility - JSON to convert the collection to a JSON string and skipping the internal collection completely, but the message being sent is always blank apart from LegalEntityID and Source system.
This is a grab of the RequestData output.
Content-Length: 362
Expect: 100-continue
Connection: Keep-Alive
{
"MessageBody": {
"LegalEntityId": "Test",
"SourceSystem": "RPA",
"JournalLines": [
{
"SourceSystemId": "",
"Date": "",
"ProjectId": "",
"EmplId": "",
"ICWarehouse": "",
"ICLocation": "",
"Qty": ,
"ItemId": "",
"WorkorderId": ""
}
]
}
}
Answered! Go to Answer.
11-01-23 07:52 AM
Hi Everybody.
I think i have fixed it 😄
Now at least the RequestData output fills in my data.
The fix was to send the Collection to the Object, use a MultiCalc step, to split it into single dataitems, and then pass those to the call.
Right now i am waiting for someone on the other end to veryfy that something has been recieved.
10-01-23 01:00 AM
10-01-23 10:55 AM
10-01-23 11:07 AM
Thanks for the suggestion.
So it should look like this instead if i understand you correctly?
{
"MessageBody": {
"LegalEntityId": "[LegalEntityID]",
"SourceSystem": "[SourceSystem]",
"JournalLines": "[JournalLines]"
}
}
Unfortunatly when i do that i get "ERROR: Internal : Unexpected error Error during Web API HTTP Request."
10-01-23 11:17 AM
10-01-23 12:43 PM
Hi again @Michael ONeil
Thanks for the suggestion,
When i try that, i get this as the RequestData
Content-Length: 351
Expect: 100-continue
Connection: Keep-Alive
{
"MessageBody": {
"LegalEntityId": "Test",
"SourceSystem": "RPA",
"JournalLines":
{
"SourceSystemId": "",
"Date": "",
"ProjectId": "",
"EmplId": "",
"ICWarehouse": "",
"ICLocation": "",
"Qty": ,
"ItemId": "",
"WorkorderId": ""
}
}
}
So unfortunatly still not success, even though i have made sure the names in the collection are identical to the ones in the template.
10-01-23 02:08 PM
10-01-23 02:31 PM
StringBuilder payload = new StringBuilder();
payload.Append("{");
payload.Append("\"MessageBody\": {");
payload.Append("\"LegalEntityId\": \"" + LegalEntityID + "\",");
payload.Append("\"SourceSystem\": \"" + SourceSystem + "\",");
payload.Append("\"JournalLines\": [");
foreach (DataRow journalLine in JournalLines.Rows)
{
payload.Append("{");
payload.Append("\"SourceSystemId\": \"" + journalLine["SourceSystemId"].ToString() + "\",");
payload.Append("\"Date\": \"" + journalLine["Date"].ToString() + "\",");
payload.Append("\"ProjectId\": \"" + journalLine["ProjectId"].ToString() + "\",");
payload.Append("\"EmplId\": \"" + journalLine["EmplId"].ToString() + "\",");
payload.Append("\"ICWarehouse\": \"" + journalLine["ICWarehouse"].ToString() + "\",");
payload.Append("\"ICLocation\": \"" + journalLine["ICLocation"].ToString() + "\",");
payload.Append("\"Qty\": " + journalLine["Qty"].ToString() + ",");
payload.Append("\"ItemId\": \"" + journalLine["ItemId"].ToString() + "\",");
payload.Append("\"WorkorderId\": \"" + journalLine["WorkorderId"].ToString() + "\",");
payload.Append("},");
}
payload.Append("]");
payload.Append("}");
payload.Append("}");
Request_Content = payload.ToString();
10-01-23 02:46 PM
[
{
"data": {
"rows": [
{
"ItemKey": {
"valueType": "text",
"value": "001"
} ,
"name": {
"valueType": "text",
"value": "zdenek"
},
"surname": {
"valueType": "text",
"value": "kabatek"
}
}
]
},
"deferredDate": "2021-04-11T19:00:00Z",
"priority": 0,
"tags": [
"This is testing REST API"
],
"status": "Ready for processing"
}
]
11-01-23 07:14 AM