JSD create request POST problem with values from Insight

rest-api

#1

Hi People,

I’ve got a problem trying to use JSD API 7.6.1 to create a simple incident…

So far, I’m POSTing values and they are recognized OK (summary, description, category), but some other values are from Insight and those are just not recognized…

This is my POST:
$ curl -stderr -u apiuser:*** -H “Content-Type:application/json” -X POST -d ‘{“serviceDeskId”:“1”, “requestTypeId”:“4”, “requestFieldValues”:{“summary”:“LLagos JSD REST API”, “description”:“Ejemplo desde API JSD”, “customfield_10400”:{“id”:“10200”}, “customfield_10318”:[{“value”:“SER-15”}], “customfield_10328”:[{“value”:“SER-1”}], “customfield_10329”:[{“value”:“SER-18”}] }}’ http://…:8080/rest/servicedeskapi/request | python3 -mjson.tool
{
“errorMessage”: “Su solicitud no pudo ser creada. Compruebe que los campos han sido rellenados correctamente. Ingrese un valor para el campo obligatorio ‘Servicio’ Ingrese un valor para el campo obligatorio ‘Zona’ Ingrese un valor para el campo obligatorio ‘Componente’”,
“i18nErrorMessage”: {
“i18nKey”: “sd.validation.request.creation.failure.required.field”,
“parameters”: [
“Ingrese un valor para el campo obligatorio ‘Servicio’ Ingrese un valor para el campo obligatorio ‘Zona’ Ingrese un valor para el campo obligatorio ‘Componente’”
]
}
}

Sorry for the spanish but it simply says fields “Zona” (cf10318), “Servicio” (cf10328), and “Componente” (cf10329) are just not recognized… not even a “bad format” or “incorrect value” error… it just keeps saying “not here; please add them”…

So, what is the correct format for this?

I’ve also tried what the doc says, that the array should be “requestFieldValues: []” but that throws a very ugly java exception…

$ curl -stderr -u apiuser:*** -H “Content-Type:application/json” -X POST -d ‘{“serviceDeskId”:“1”, “requestTypeId”:“4”, “requestFieldValues”:[{“summary”:“LLagos JSD REST API”, “description”:“Ejemplo desde API JSD”, “customfield_10400”:{“id”:“10200”}, “customfield_10329”:{“value”:“SER-18”}} ]}’ http://…:8080/rest/servicedeskapi/request

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>500</status-code><message>Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token

at [Source: org.apache.catalina.connector.CoyoteInputStream@9aebb53; line: 1, column: 42]</message><stack-trace>org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token

at [Source: org.apache.catalina.connector.CoyoteInputStream@9aebb53; line: 1, column: 42]&#xD;

at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)&#xD;

at org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:219)&#xD;

at org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:212)&#xD;

at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:246)&#xD;

at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:33)&#xD;

at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)&#xD;

at org.codehaus.jackson.map.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:905)&#xD;

at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObjectUsingNonDefault(BeanDeserializer.java:739)&#xD;

at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:683)&#xD;

at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)&#xD;

at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)&#xD;

at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)&#xD;

at java.lang.Thread.run(Thread.java:748)&#xD;

</stack-trace></status>

Really don’t know what else to try…

Thanks a lot!


#2

Hello @leo.lagos,

It is possible that those custom fields are not recognized by the specific issue type. Since you’re more interested with creating a JSD request, try getting the allowed fields for the specific request type by calling Get request type fields REST API and verify if the fields are there.

Cheers,
Ian


#3

Give it a try with
“customfield_10329”:[{“key”:“SER-18”}] insetad of “customfield_10329”:[{“value”:“SER-18”}]


#4

Thanks Filip… that was the mistake… I used “key” and it worked ok! Thanks!!!