Good day community,

 

I'm having trouble with adding the correct JSON path for my request body.

 

I have to send a POST request with the following JSON below:

{
  "members": [
    {
      "@odata.type": "--TYPE HERE--",
      "user@odata.bind": "--USER 1 HERE--"
    },
    {
      "@odata.type": "--TYPE HERE--",
      "user@odata.bind": "--USER 2 HERE--"
    }
  ]
}

This is how my parameter structure looks:

Generated JSON here:

{
	"chatType": "oneOnOne",
	"members": [
		{
			"@odata": {
				"type": "--TYPE HERE--"
			},
			"user@odata": {
				"bind": "--USER 1 HERE--"
			}
		}
	]
}

The problem with this structure is that it generates a nested key for type under @odata, and for bind as well. I don't wan't this to happen if possible.

 

Is there any way to get this to work using parameters in web service? Or would my only resort be to generate the request body via script?

Like 0

Like

2 comments

Hello,

 

The body of the webservice seems to be generated properly since "members" is the array of objects "@odata" and "user@odata". The request was properly parsed and that's why you saw the result as on the screenshot. If this structure won't work in your business case then a separate script task should be created to sent the request.

 

Best regards,

Oscar 

Hi Oscar,

 

Thank you for you response.

 

In forming the json path, I would have made it as $.[members]["@odata.dataType"] or $.[members]["user@odata.bind"], but I'm guessing that this is not possible using the built-in function (nesting parameters) in Creatio?

 

I think I'll instead be resorting to creating a script task for this.

 

Thank you!

 

Lyle

Show all comments

I'm getting a reply such as this JSON

        "company_naics_code": [
            "3271201",
            "3332491",
            "327213",
            "333249",
            "3339930",
            "3333187"
        ],

I've linked the propper array (see pictures), but the "3271201" value and so on are not saved to any parameter.

https://prnt.sc/1rli55a

https://prnt.sc/1rli5ii

How do I handle these values in the Web service method page? Surely, I need to use some nested parameter to use the retrieved vaules. But how do I format my Path to element (JSONPath) corrently when they dont have a name?

Like 1

Like

1 comments
Best reply

It's better to deserialize the JSON string directly inside the business process or the logic that you will use when calling the web service and then substruct needed values and pass them to either process parameters or use them according to your needs. Something like this in C#:

or (in case something should be performed from the client side):

If you are going to use the web-service inside the business process don't forget to add Newtonsoft.Json.Linq using in the process properties.

It's better to deserialize the JSON string directly inside the business process or the logic that you will use when calling the web service and then substruct needed values and pass them to either process parameters or use them according to your needs. Something like this in C#:

or (in case something should be performed from the client side):

If you are going to use the web-service inside the business process don't forget to add Newtonsoft.Json.Linq using in the process properties.

Show all comments