cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

134
Views
0
Helpful
2
Replies
khgrant
Cisco Employee

ReST with JSON payload

Hi Folks,

I’m having trouble creating a service instance via ReST PUT with JSON payload. It works with xml payload, no problems.

I see this note in the 4.01 doc – is it still valid?

Should I assume this is broken and move on?


XML OR JSON FORMAT? Both XML and JSON are supported formats for requests and response data, but using JSON for configuration is currently not as mature and clearly defined as XML - which is used by NETCONF. It is therefore recommend to use XML encoding


Here’s the error response:

{

"errors": {

"error": [

{

"error-message": "{member_name_not_string,rcbrace}",

"error-urlpath": "/api/running/services/tunnel:tunnel/TEST2",

"error-tag": "malformed-message"

}

]

  }

}

Here’s my PUT payload:

{

"tunnel:tunnel": {

"name": "TEST2",

"tunnel-head": [

{

"name": "n54ny21"

}

],

"tunnel-tail": [

{

"name": "sffca21"

}

],

"tunnel-id": 777,

"ipsla": {

"source-port": 1212,

"dest-port": 9191,

"start-after": 33

},

  }

}

Here’s the output of a GET for another instance:

{

"tunnel:tunnel": {

"name": "TEST1",

"tunnel-head": [

{

"name": "n54ny20"

}

],

"tunnel-tail": [

{

"name": "sffca20"

}

],

"tunnel-id": 777,

"ipsla": {

"source-port": 1111,

"dest-port": 9999,

"start-after": 33

},

"operations": {

"check-sync": "/api/running/services/tunnel:tunnel/TEST1/_operations/check-sync",

"deep-check-sync": "/api/running/services/tunnel:tunnel/TEST1/_operations/deep-check-sync",

"re-deploy": "/api/running/services/tunnel:tunnel/TEST1/_operations/re-deploy",

"get-modifications": "/api/running/services/tunnel:tunnel/TEST1/_operations/get-modifications",

"un-deploy": "/api/running/services/tunnel:tunnel/TEST1/_operations/un-deploy",

"self-test": "/api/running/services/tunnel:tunnel/TEST1/_operations/self-test"

}

  }

}

Thanks,

-Don

  ______________________________________________________________________
  Don Heidrich    

1 ACCEPTED SOLUTION

Accepted Solutions
khgrant
Cisco Employee

Hi Don,

Check the , below.

Thanks,

/Jason

From: "Don Heidrich (dheidric)" <dheidric@cisco.com>
Date: Friday, December 4, 2015 at 11:27 AM
To: "service_orchestration(mailer list)" <service_orchestration@cisco.com>
Subject: ReST with JSON payload

Hi Folks,

I’m having trouble creating a service instance via ReST PUT with JSON payload. It works with xml payload, no problems.

I see this note in the 4.01 doc – is it still valid?

Should I assume this is broken and move on?

XML OR JSON FORMAT? Both XML and JSON are supported formats for requests and response data, but using JSON for configuration is currently not as mature and clearly defined as XML - which is used by NETCONF. It is therefore recommend to use XML encoding

   

Here’s the error response:

{

  "errors": {

    "error": [

      {

"error-message": "{member_name_not_string,rcbrace}",

"error-urlpath": "/api/running/services/tunnel:tunnel/TEST2",

        "error-tag": "malformed-message"

      }

    ]

  }

}

Here’s my PUT payload:

{

  "tunnel:tunnel": {

    "name": "TEST2",

    "tunnel-head": [

      {

        "name": "n54ny21"

      }

    ],

    "tunnel-tail": [

      {

        "name": "sffca21"

      }

    ],

    "tunnel-id": 777,

    "ipsla": {

      "source-port": 1212,

      "dest-port": 9191,

      "start-after": 33

},   <<<<———remove

  }

}

Here’s the output of a GET for another instance:

{

  "tunnel:tunnel": {

    "name": "TEST1",

    "tunnel-head": [

      {

        "name": "n54ny20"

      }

    ],

    "tunnel-tail": [

      {

        "name": "sffca20"

      }

    ],

    "tunnel-id": 777,

    "ipsla": {

      "source-port": 1111,

      "dest-port": 9999,

      "start-after": 33

    },

    "operations": {

      "check-sync": "/api/running/services/tunnel:tunnel/TEST1/_operations/check-sync",

      "deep-check-sync": "/api/running/services/tunnel:tunnel/TEST1/_operations/deep-check-sync",

      "re-deploy": "/api/running/services/tunnel:tunnel/TEST1/_operations/re-deploy",

      "get-modifications": "/api/running/services/tunnel:tunnel/TEST1/_operations/get-modifications",

      "un-deploy": "/api/running/services/tunnel:tunnel/TEST1/_operations/un-deploy",

      "self-test": "/api/running/services/tunnel:tunnel/TEST1/_operations/self-test"

    }

  }

}

 

/Jason Yen

View solution in original post

2 REPLIES 2
khgrant
Cisco Employee

Hi Don,

Check the , below.

Thanks,

/Jason

From: "Don Heidrich (dheidric)" <dheidric@cisco.com>
Date: Friday, December 4, 2015 at 11:27 AM
To: "service_orchestration(mailer list)" <service_orchestration@cisco.com>
Subject: ReST with JSON payload

Hi Folks,

I’m having trouble creating a service instance via ReST PUT with JSON payload. It works with xml payload, no problems.

I see this note in the 4.01 doc – is it still valid?

Should I assume this is broken and move on?

XML OR JSON FORMAT? Both XML and JSON are supported formats for requests and response data, but using JSON for configuration is currently not as mature and clearly defined as XML - which is used by NETCONF. It is therefore recommend to use XML encoding

   

Here’s the error response:

{

  "errors": {

    "error": [

      {

"error-message": "{member_name_not_string,rcbrace}",

"error-urlpath": "/api/running/services/tunnel:tunnel/TEST2",

        "error-tag": "malformed-message"

      }

    ]

  }

}

Here’s my PUT payload:

{

  "tunnel:tunnel": {

    "name": "TEST2",

    "tunnel-head": [

      {

        "name": "n54ny21"

      }

    ],

    "tunnel-tail": [

      {

        "name": "sffca21"

      }

    ],

    "tunnel-id": 777,

    "ipsla": {

      "source-port": 1212,

      "dest-port": 9191,

      "start-after": 33

},   <<<<———remove

  }

}

Here’s the output of a GET for another instance:

{

  "tunnel:tunnel": {

    "name": "TEST1",

    "tunnel-head": [

      {

        "name": "n54ny20"

      }

    ],

    "tunnel-tail": [

      {

        "name": "sffca20"

      }

    ],

    "tunnel-id": 777,

    "ipsla": {

      "source-port": 1111,

      "dest-port": 9999,

      "start-after": 33

    },

    "operations": {

      "check-sync": "/api/running/services/tunnel:tunnel/TEST1/_operations/check-sync",

      "deep-check-sync": "/api/running/services/tunnel:tunnel/TEST1/_operations/deep-check-sync",

      "re-deploy": "/api/running/services/tunnel:tunnel/TEST1/_operations/re-deploy",

      "get-modifications": "/api/running/services/tunnel:tunnel/TEST1/_operations/get-modifications",

      "un-deploy": "/api/running/services/tunnel:tunnel/TEST1/_operations/un-deploy",

      "self-test": "/api/running/services/tunnel:tunnel/TEST1/_operations/self-test"

    }

  }

}

 

/Jason Yen

khgrant
Cisco Employee

SUCCESS!

(doh!)

Thanks Jason,

-Don

Create
Recognize Your Peers
Content for Community-Ad