Inconsistencies in the json body sent by web service connector

Hi everyone,
I’m trying to create a customized json body.
I didn’t manage to get rid of the quotes so I’m using a token to replace some values in the body.
However, I realized that from one request to the other (different entitlements for creation), the json body is quoted differently (around the %locationsIds%) even though it is the exact same operation for both. (I print it in the logs in the before operation rule to see it before modifying it).
I’m not sure why this is happening?

[_afterRule=Web Service After Operation Rule Debug, _beforeRule=app Creation Before Operation Rule - User, _contextUrl=\/personnel\/1657\/user, _fullUrl=URL, _httpMethodType=POST, _operationType=Create Account, _rootPath=$, _uniqueNameForEndPoint=Create User - Second Step, paginationSteps=null, pagingInitialOffset=0, pagingSize=50, _resMappingObj={UserId=Id}, _header={x-api-username=, x-api-key=, Content-Type=application\/json}, _body={jsonBody={\n \"IsArchived\": false,\n \"UserName\": \"TU1\",\n \"Password\": \"a password\",\n \"UserGroupId\": 14,\n \"Locations\": \n %LocationIds%\n}, bodyFormat=raw}, _responseCode=[200], _sequenceNumberForEndpoint=9, xpathNamespaces={}, possibleHttpErrors={}]

[_afterRule=Web Service After Operation Rule Debug, _beforeRule=app Creation Before Operation Rule - User, _contextUrl=\/personnel\/1658\/user, _fullUrl=URL, _httpMethodType=POST, _operationType=Create Account, _rootPath=$, _uniqueNameForEndPoint=Create User - Second Step, paginationSteps=null, pagingInitialOffset=0, pagingSize=50, _resMappingObj={UserId=Id}, _header={x-api-username=, x-api-key=, Content-Type=application\/json}, _body={jsonBody={\"IsArchived\":false,\"UserName\":\"TU2\",\"Password\":\"a password\", \"Locations\":\"%LocationIds%\"}, bodyFormat=raw}, _responseCode=[200], _sequenceNumberForEndpoint=9, xpathNamespaces={}, possibleHttpErrors={}]

The original JSON body in the source for reference:

{\n \"IsArchived\": false,\n \"UserName\": \"$plan.UserName$\",\n \"Password\": \"$plan.Password$\",\n \"UserGroupId\": $plan.UserGroupId$,\n \"Locations\": \n %LocationIds%\n}

@veroniqueb - That’s strange. But you could have used a value like LOCATION-IDs or LOCATION-ID-REPLACER for better understanding to replace in your rule rather than having % included in your replacement variable.

1 Like

I figured out that it was depending on the addRemoveEntInSingleReq. Whether the plan.[entitlements] are sent as a list or single value.

Ah, in that case, you need to take into consideration the object type (list or string) and operation type(add or remove) to construct your final body

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.