Hi @Anil Sagar,
I am trying to create a new user on the on prem instance and receiving following error -
curl -v -u "<user_name>:<password>" "http://<IP>:<Port>/v1/users" -H "Content-Type:application/json" -X POST -d "{"firstName":"edgeorgadmin","lastName":"edgeorgadmin","password":"Apigee2017","emailId":"edgeorgadmin@abc.com"}"
* About to connect() to <IP> port <port> (#0)
* Trying <IP>.... connected
* Connected to ##########################
* Server auth using Basic with user ##############
> POST /v1/users HTTP/1.1
> Authorization: Basic ############################
> User-Agent: curl/7.19.7##########################################################
> Host: #############################
> Accept: */*
> Content-Type:application/json
> Content-Length: 100
>
< HTTP/1.1 400 Bad Request
<
< Content-Type: application/json
<
< Content-Length: 225
<
{
"message" : "Unexpected character ('f' (code 102)): was expecting double-quote to start field name\n at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@50987e78; line: 1, column: 3]",
"contexts" : [ ]
* Connection #0 to host ######## left intact
* Closing connection #0
Can you please help and let me know what is the issue here?
Thanks,
Santosh
Solved! Go to Solution.
In your curl command don't enclose the JSON string in double quotes.
curl -v -u " : " "http:// : /v1/users" -H "Content-Type:application/json" -X POST -d '{"firstName":"edgeorgadmin","lastName":"edgeorgadmin","password":"Apigee2017","emailId":"edgeorgadmin@abc.com"}'
This should work.
Cheers!!
In your curl command don't enclose the JSON string in double quotes.
curl -v -u " : " "http:// : /v1/users" -H "Content-Type:application/json" -X POST -d '{"firstName":"edgeorgadmin","lastName":"edgeorgadmin","password":"Apigee2017","emailId":"edgeorgadmin@abc.com"}'
This should work.
Cheers!!
Thanks @Mohammed Zuber - I had tried the same but had passed all data as well in single quotes.!
Regards,
Santosh
The problem in your command is the misused of double quotes:
-d "{"firstName":
You are opening " after -d and then using " for the json payload. Replace the " after -d by single ' as showed on the example below.
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |