HTTP Workflow Error

Hi ,

I have built the workflow using “HTTP Request” as action.
In the Request body, Am trying to pass the attribute which holds the JSON Body (created it using Webservice after rule).
Attribute Name : ppdSnowflakeStudyRoleBodyUpdate
Value : {“employeeDetails”:{“employeeName”:{“id”:“name”,“legacyId”:“value”,“firstName”:“value”,“middleName”:“L”,“lastName”:“value”},“employeeLogin”:“value”,“employeeEmail”:“value”,“employeeStatus”:“active”},“access”:[{“studyId”:“value”,“studyName”:“value”,“roleId”:“value”,“role”:“value”,“status”:“active”,“obsolete”:false,“personType”:“Internal”,“grantRelatedRecord”:false,“startDate”:“2015-04-01T18:22:13”,“endDate”:“2015-04-01T18:22:13”,“creationTimestamp”:“2015-04-01T18:22:13”,“lastUpdatedTimestamp”:“2015-04-01T18:23:30”}]}

WorkflowExecutionFailed with error : {“error”:“actionStep(HTTP Request) Error: task failed: activity error (type: sp:external:http:v2, scheduledEventID: 5, startedEventID: 6, identity: [email protected]@): json: cannot unmarshal string into Go struct field externalHTTPInputV2.jsonRequestBody of type map[string]interface {} (type: Error Parsing Input, retryable: false): json: cannot unmarshal string into Go struct field externalHTTPInputV2.jsonRequestBody of type map[string]interface {} (type: UnmarshalTypeError, retryable: true)”}

Can you guide us?

Can you please download your workflow script and send it?


I wonder if the attributes.ppdSnowflakeStudyRoleBody is encoded as a string instead of an object. The workflow execution should log the contents of the attribute. What does it look like?

Do you think this issue exist in our tenant?

This is a different issue. Here’s what’s happening:

When you select a Request Content Type of JSON, the workflow expects a JSON object in the Request Body field. A valid JSON request body would look like this:

{
  "key": "value"
}

In your case, you are populating the Request Body with a variable from your data stream, ppdSnowflakeStudyRoleBodyUpdate. You may have thought that this variable is a JSON object, but when this variable was created in your webservice after rule, it was encoded as a string, not an object. A JSON object encoded as a string will appear like this in the workflow input:

"{\"key\":\"value\"}"

If you look closely at your workflow log, you can see that the value being passed into the body of your HTTP request is encoded as a string, hence the error that it can’t be unmarshalled.

Source accounts can’t store objects, they can only store booleans, integers, and strings. Source accounts aren’t meant to handle complicated objects like this. Workflows doesn’t have the ability to unmarshal a string into an object, so there’s only two solutions to this:

  1. If you control the service that you are sending this HTTP request to, then maybe you can update the service to accept text in addition to json. Then you can add some logic to your service to convert a string into an object. All you would need to do in your HTTP Request action is change the Request Content Type to text.
  2. Research a better way to accomplish what you are trying to do with ppdSnowflakeStudyRoleBodyUpdate. Storing it in a source account as an object is not a recommended approach. There might be other ways to accomplish what you are trying to do.
1 Like

Thanks Colin for your immediate assistance.

Even If I try to pass the JSON body value directly without using attribute ppdSnowflakeStudyRoleBodyUpdate, I got the same error.

Attached screenshot

Can you send me the script?

A post was split to a new topic: Workflows: How to dynamically create request body in HTTP action


That looks like a bug. Your request body is a list of objects. Technically, a JSON schema that begins as an array is not valid according to the JSON RFC. In practice, most JSON tooling will accept an array at the top level, so I’m going to log this as a bug so our Workflows team can fix this and allow arrays at the top level.

However, it’s interesting that you made your input an array of objects when the previous input that came from the account attribute was just an object. If you remove the array wrapping your object it should work.