cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
436
Views
0
Helpful
0
Replies

PUT/POST not succeeded in REST API on CSR1000V

nklo_2010
Level 1
Level 1

Hi all,

I'm trying to do REST API on CSR1000V (by setting up the OVF VM which is of ios xe  3.11s).

Succeeded in GET, but everytime doing PUT, it says like below, that there is unsupported content which I sent thru' JSON:

C:\Users\curl>curl https://192.168.241.26/api/v1/global/
host-name -H "x-auth-token: DHLjE+f3MaC85SozPTodycDFZZHxsu9otg1pV2cZjF8=" -H "A
ccept:application/json" -v -k
* Trying 192.168.241.26...
* TCP_NODELAY set
* Connected to 192.168.241.26 (192.168.241.26) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.0 (IN), TLS handshake, Server hello (2):
* TLSv1.0 (IN), TLS handshake, Certificate (11):
* TLSv1.0 (IN), TLS handshake, Server key exchange (12):
* TLSv1.0 (IN), TLS handshake, Server finished (14):
* TLSv1.0 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.0 (OUT), TLS change cipher, Client hello (1):
* TLSv1.0 (OUT), TLS handshake, Finished (20):
* TLSv1.0 (IN), TLS change cipher, Client hello (1):
* TLSv1.0 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.0 / DHE-RSA-AES256-SHA
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; O=Cisco; ST=California; CN=restful_api
* start date: May 26 05:32:46 2013 GMT
* expire date: May 24 05:32:46 2023 GMT
* issuer: C=US; O=Cisco; ST=California; CN=restful_api
* SSL certificate verify result: self signed certificate (18), continuing anywa
y.
> GET /api/v1/global/host-name HTTP/1.1
> Host: 192.168.241.26
> User-Agent: curl/7.50.3
> x-auth-token: DHLjE+f3MaC85SozPTodycDFZZHxsu9otg1pV2cZjF8=
> Accept:application/json
>
< HTTP/1.1 200 OK
< Server: nginx/1.4.2
< Date: Tue, 11 Oct 2016 02:44:15 GMT
< Content-Type: application/json
< Content-Length: 53
< Connection: keep-alive
<
{"kind": "object#host-name", "host-name": "csr1kv-1"}* Curl_http_done: called pr
emature == 0
* Connection #0 to host 192.168.241.26 left intact

C:\Users\curl>curl -X PUT https://192.168.241.26/api/v1/
global/host-name -H "x-auth-token: DHLjE+f3MaC85SozPTodycDFZZHxsu9otg1pV2cZjF8="
-H "Accept:application/json" -v -k -H "content-type:application/json" -d '{
"host-name":"csr1000v1"}'
* Trying 192.168.241.26...
* TCP_NODELAY set
* Connected to 192.168.241.26 (192.168.241.26) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.0 (IN), TLS handshake, Server hello (2):
* TLSv1.0 (IN), TLS handshake, Certificate (11):
* TLSv1.0 (IN), TLS handshake, Server key exchange (12):
* TLSv1.0 (IN), TLS handshake, Server finished (14):
* TLSv1.0 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.0 (OUT), TLS change cipher, Client hello (1):
* TLSv1.0 (OUT), TLS handshake, Finished (20):
* TLSv1.0 (IN), TLS change cipher, Client hello (1):
* TLSv1.0 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.0 / DHE-RSA-AES256-SHA
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; O=Cisco; ST=California; CN=restful_api
* start date: May 26 05:32:46 2013 GMT
* expire date: May 24 05:32:46 2023 GMT
* issuer: C=US; O=Cisco; ST=California; CN=restful_api
* SSL certificate verify result: self signed certificate (18), continuing anywa
y.
> PUT /api/v1/global/host-name HTTP/1.1
> Host: 192.168.241.26
> User-Agent: curl/7.50.3
> x-auth-token: DHLjE+f3MaC85SozPTodycDFZZHxsu9otg1pV2cZjF8=
> Accept:application/json
> content-type:application/json
> Content-Length: 23
>
* upload completely sent off: 23 out of 23 bytes
< HTTP/1.1 400 BAD REQUEST
< Server: nginx/1.4.2
< Date: Tue, 11 Oct 2016 02:45:57 GMT
< Content-Type: application/json
< Content-Length: 147
< Connection: keep-alive
<
{"error-code": 400, "error-message": "HTTP Bad Request", "detail": "JSON body in
the request is either malformed or contains unsupported encoding"}* Curl_http_d
one: called premature == 0
* Connection #0 to host 192.168.241.26 left intact

I follow the instruction at http://www.cisco.com/c/en/us/td/docs/routers/csr1000/software/restapi/restapi/RESTAPIglobal.html, and tried some other PUT, eg. domain-name,  but get the same error....

Appreciate if any kind advice to solve this.

Thanks.

0 Replies 0