Using servicedeskapi/customer to create a new customer

MP AK I'm New Here Dec 22, 2017

I tried to create a new service desk customer via the REST api according to this description: https://developer.atlassian.com/cloud/jira/service-desk/rest/#api-customer-post

However the following call fails with an exception in curl and the service desk log:

curl -D- -u admin:admin -X POST --data "{\"email\":\"fred@example.com\",\"displayName\":\"Fred Foo\"}" -H "Content-Type: application/json" -H "X-ExperimentalApi: opt-in" http://localhost:8080/rest/servicedeskapi/customer

curl output:

[...]
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>500</status-code><message>Unexpected character ('\' (code 92)): was expecting double-quote to start field name
at [Source: org.apache.catalina.connector.CoyoteInputStream@c21c873; line: 1, column: 3]</message><stack-trace>org.codehaus.jackson.JsonParseException: Unexpected character ('\' (code 92)): was expecting double-quote to start field name
at [Source: org.apache.catalina.connector.CoyoteInputStream@c21c873; line: 1, column: 3]&#xD;
[...]

Service desk log:

[...]
 
/rest/servicedeskapi/customer [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: No content to map to Object due to end of input

java.io.EOFException: No content to map to Object due to end of input

                at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2775)

                at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2691)

                at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)

                at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)

                at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:490)

                at com.sun.jersey.spi.container.AdaptingContainerRequest.getEntity(AdaptingContainerRequest.java:236)

                ... 15 filtered
[...]

Like the curl output states, there seems to be a problem with the escape sequence. So I tried to read the data from a file. In this case the escape sequences are not necessary. This time the API call created the customer.

 

Am I using the API in a wrong way or is this an issue of the service desk?

1 answer

0 vote
Alexey Matveev Community Champion Dec 22, 2017

Hello,

I think it is not about the Jira Service Desk Api, but it is about the curl. You can find posts with the same problem

https://stackoverflow.com/questions/4514199/how-to-send-double-quote-in-d-parameter-for-curl-exe

MP AK I'm New Here Dec 22, 2017

Hey Alexey,

thanks for the quick reply! In the mean time I figured it out myself. The problem was not about the escape characters, but about missing spaces (as strange as it sounds).

The following call works for me:

curl.exe -D- -u admin:admin -X POST -d "{\"email\": \"test@example.com\", \"fullName\": \"Fred Example\" }" -H "Content-Type: application/json" -H "X-ExperimentalApi: opt-in" https://localhost:8080/rest/servicedeskapi/customer -k
Alexey Matveev Community Champion Dec 22, 2017

Good to hear

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Mar 09, 2018 in Jira Service Desk

E.L. Fridge's take on education, Jira Service Desk, and creative Jira use cases

...word of mouth, so by 2016, we were working with several other entities on campus to implement Jira Service Desk . The Atlassian motto of “for every team” has really come true for us in this case. We...

1,228 views 2 14
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you