I ran into a problem when I created the variable. I specify “Infer from a sample JSON payload” scheme:
{
"Source": "string",
"Data": {
"Request": {
"Top": 0,
"Skip": 0
}
}
}
and also filling in the Default Value (because you can’t do a SetProperty in DataMapping task without it):
{
"Source": "",
"Data": {
"Request": {
"Top": 0,
"Skip": 0
}
}
}
Then this value is changed in the DataMapping task and passed to the body Rest Api call task
The problem is that I need to get an integer (0), but it sends a double (0.0).
Api response error:
{"apiRequest.Data.Request.Top":["Input string '0.0' is not a valid integer. Path 'Data.Request.Top', line 16, position 16."],"apiRequest.Data.Request.Skip":["Input string '0.0' is not a valid integer. Path 'Data.Request.Skip', line 17, position 17."]}
As I see in the received json scheme:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"Data": {
"type": "object",
"properties": {
"Request": {
"type": "object",
"properties": {
"Top": {
"type": "number"
},
"Skip": {
"type": "number"
},
}
}
}
}
}
}
Is it possible to explicitly specify integer type in json scheme, because when I change type to integer - I get an error:
Failed to save changes. Please try again later. Error: Message: instance type (number) does not match any allowed primitive type (allowed: ["integer"]) Schema Path:"/properties/Data/properties/Request/properties/Skip" Message: instance type (number) does not match any allowed primitive type (allowed: ["integer"]) Schema Path:"/properties/Data/properties/Request/properties/Top"
The second part of the question - Can I not set a default value for a variable? If I need to create a variable and then set values for it, I use the DataMapping task Json.SetProperty() method. But if the value hasn’t been set to default (for example: “” for an array) - an error happens.
'Failed to fetch the input value. Reason: [Failed to evaluate transform expression value. Reason: [Value null does not represent a JSON array.]]'
