Post Action not working in workflow

I believe I am having an issue with the JSON format. In the body I have tested this out in postman and it works. But in the resource query I am using raw body because the JSON option is key values. Inside my post body I have nested objects and do not know how to input that as a key value.

This error leads me to believe it is using xml as the type.
{"rawXml":"\r\n The request entity's media type 'text/plain' is not supported for this resource.\r\n","parsedXml":{"Error":{"Message":["The request entity's media type 'text/plain' is not supported for this resource."]}}}

Hi @tbommer, welcome to the community :wave:

Your issue here lies with line 3 of your Body.
Try connecting the string in a JS acceptable format:

{...
  "Note" : "BGSyncID - " + {{ your reference here }} + "WO Created ... Service Request.",
...}

Because there's a broken string there, the raw body is treating this as plain text and not necessarily a JSON formatted body.

Thank you for the help. This is the body now. I have made the adjustments and still the same error.

{
"Type": "WorkOrder",
"Note": "BGSyncID - " + {{startTrigger.data.call_provider_bgsync_id}} + "WO Created by Incoming Electronic Service Request.",
"ID": "00000000-0000-0000-0000-000000000000",
"InvoiceNumber": 0,
"Completed": false,
"WorkflowStage": "Unassigned",
"Contact": {
"ID": "0acbf077-027a-4128-bdd9-6d6863020c23"
},
"ServiceItem": {
"ID":"{{CreateServiceItem.data.ID}}"
},
"ServicePackages": {
"ItemCollection": [
{
"ID": "00000000-0000-0000-0000-000000000000",
"Chapter": "Service",
"Code": "ESR-FN",
"Rank": 1,
"ServicePackageHeader": {
"Title": "Electronic Service Request for - " + {{startTrigger.data.bgsync_request_id}},
"Description": "Customer Code: " + {{startTrigger.data.customer_code}} + "Request Type: " + {{startTrigger.data.request_type}} + "Address: " + {{ServDispObject.data.Address}} + " " + {{ServDispObject.data.EventCity}} + ", " + {{ServDispObject.data.EventState}} +" " + {{ServDispObject.data.EventZip}} + "Trouble: " + {{ServDispObject.data.Trouble}} + "Service Needed: " + {{ServDispObject.data['Service Needed']}} + "Unit Type: " + {{ServDispObject.data.UnitType}} + "Event ID: " + {{ServDispObject.data['Event Id']}} + "Date Time Occured: " + {{ServDispObject.data.DateTimeOccured}} + "Call Back Phone: " + {{ServDispObject.data.CallbackPhone}} + "Weight To Tow: " + {{ServDispObject.data['If Loaded Total Weight- (Weight to Tow)']}} + "Keys Location: " + {{ServDispObject.data['If driver is not riding back, where are the keys?']}} + "Driver Riding Back: " + {{ServDispObject.data['Driver Riding back?']}} + "Number of Drivers: " + {{ServDispObject.data['Number of Drivers?']}} + "Number of Drivers: " + {{ServDispObject.data['Number of Drivers?']}} + "Driver with Unit: " + {{ServDispObject.data['Driver with the unit?']}} + "Notes for Tractor\Trailer: " + {{ServDispObject.data['Notes for Tractor/Trailer Specific Information']}} + "Bill To (Is this a Warranty Tow/To be Billed to Dealer?): " + {{ServDispObject.data['Bill To (Is this a Warranty Tow/To be Billed to Dealer?)']}} + "Requested By: " + {{ServDispObject.data['Requested by']}} + "Destination (Where to Tow to): " + {{ServDispObject.data['Destination (Where to Tow to)']}} + "Additional Notes: " + {{ServDispObject.data['Additional Notes']}} + "Winch Out, Recover,or Tow?: " + {{ServDispObject.data['Winch Out, Recover or Tow?']}} + "Driver Phone Number: " + {{ServDispObject.data['Driver Phone Number']}}
},
"ServicePackageLines": {
"ItemCollection": [
{
"ID": "00000000-0000-0000-0000-000000000000",
"Rank": 1,
"Type": "Labor",
"Description": "Test",
"Quantity": "1",
"RateCode": "2",
"MinimumCharge": 0,
"Total": "125.00",
"Discount": 0,
"ExtendedTotal": "125.00",
"TotalCost": "125.00",
"Completed": false,
"TechnicianHour": "1"
}
]
}
}
]
}
}

Hey @tbommer, uhmm, wow. Confirming, is there only 2 properties for ServicePackageHeader: Title and Description?

Can't you use a transformer prior to this code block to format your Description field? I tried checking this but doing my head in. For cumbersome string/raw json format, I would suggest you work on this on a code block and specify how that body value should be.

Also, why are you not using a JSON Body instead of raw? Just a tip as well, try building the workflow as an app so you can easily understand the data you are passing before writing in workflows.

@jocen JSON turns to Key Value entry. And I have nested objects in the body. I am not sure how to do key value with the requirements of my JSON.

I would prefer to do this using JSON Body. Can you tell me what the key and value would be for ID below?
"ServicePackages": {
"ItemCollection": [
{
"ID": "00000000-0000-0000-0000-000000000000",
"Chapter": "Service",
"Code": "ESR-FN",
"Rank": 1,

I added


everything works fine except the carriage returns.

Then I added
image

Still getting the same error.

I got this figured out. I also had an issue in the header which ultimately resolved it. Thanks very much for your assistance @jocen

2 Likes