Page 1 of 1

Creating JSON Schema from JSON data

Posted: Thu Dec 14, 2017 4:42 pm
by sandhya.budhi
I wanted to do a REST call using a JSON file. The REST call should be made using the below JSON payload

Code: Select all

"Queue":[ 
 { 
      "YYYYYYYY",
       "AA",
       "07",
        "2017-11-14",
	false,
	"2017-11-14",
        15.2,
	"YYYYYYY",
	false,
	"SPACER",
	false,
        "07",
	"Japan export",
	"C",
        0.000,
	"NONE",
	"YYYYYY",
	false,
	false
},
{
       "XXXXXX",
       "AA",
       "07",
        "2017-11-14",
	false,
	"2017-11-14",
        15.2,
	"XXXXXXX",
	false,
	"SPACER",
	false,
        "07",
	"Japan export",
	"C",
        0.000,
	"NONE",
	"XXXXXX",
	false,
	false 
  }
]

I am creating the schema for JSON composer stage and it is giving me an error message the schema is invalid. I am looking some help in creating the JSON schema for having a JSON object inside an JSON array.

Code: Select all

  "type": "array",
  "items":[
    "type": "object",
      {
        "name": "string"
      },
      {
        "address": "string"
      },
      {
        "area": "string"
      },
      {
        "dob": "string"
      },
      {
        "Status": "boolean"
      },
      {
        "rec": "string"
      },
      {
        "counter": "number"
      },
      {
        "desig": "string"
      },
      {
        "worktool": "boolean"
      },
      {
        "desc": "string"
      },
      {
        "reman": "boolean"
      },
      {
        "area2": "string"
      },
      {
        "req_reason": "string"
      },
      {
        "suspend": "string"
      },
      {
        "seqno": "number"
      },
      {
        "crb": "string"
      },
      {
        "dcc": "string"
      },
      {
        "base": "boolean"
      },
      {
        "deleted": "boolean"
      }
]

Posted: Thu Dec 14, 2017 7:13 pm
by chulett
<added code tags>

Posted: Fri Dec 15, 2017 6:04 am
by eostic
I'm not an expert on the "standard" itself, but based on all the JSON payloads that I've seen, it is invalid. For those values to be outlined as such, they need tags.....

Try opening it with an editor or tool that supports JSON formatting. ( One that I find very useful is a plugin to Firefox, https://jsonview.com )

Here is a more typical JSON structure. Note how the tags are directly "in" the data. In the Stage, you import "the" JSON document itself --- the schema is crafted dynamically from your "real" sample:

Code: Select all

{

    "Supplier": "DEF Manufacturing",
    "Contact": "Ravi Sharma",
    "Region": "East",
    "Products": [
        {
            "name": "Widget",
            "description": "3x3 wooden cube",
            "Product Code": "753"
        },
        {
            "name": "thing",
            "description": "straight piece of stainless steel",
            "Product Code": "717"
        },
        {
            "name": "Widget2",
            "description": "3x3 wooden cube",
            "Product Code": "753"
        },
        {
            "name": "thing3",
            "description": "straight piece of stainless steel",
            "Product Code": "717"
        },
        {
            "name": "Widget3",
            "description": "3x3 wooden cube",
            "Product Code": "753"
        },
        {
            "name": "thing3",
            "description": "straight piece of stainless steel",
            "Product Code": "717"
        }
    ]

}
Ernie

Posted: Fri Dec 15, 2017 3:59 pm
by sandhya.budhi
Thanks for the response. I managed to get the JSON schema correct for JSON payload.

Is there any way I can verify the REST call made through Heirarchical stage and how it passes the arguments to REST API like mentioned below

Code: Select all

PUT https://example.com HTTP/1.1 
Authorization: Basic XXXXXXXXXXXXXXX== 
content-type: application/json 

[{ 
       "part": "123456", 
          "type": "AA", 
       "area": "XX"
 
}] 
I am trying to make the REST call and it is giving me the error - CDIER0916E: The REST step found a non-2xx status code in an HTTP response

I wanted to check whether I am passing the parameters passed to PUT method correctly

Posted: Sat Dec 16, 2017 11:12 pm
by eostic
Try the logs settings at the stage level before you enter the assembly. They "may" help here.....they are voluminous.....their location will be written i to the dslog near the start of the job.

Ernie

Posted: Thu Dec 28, 2017 12:53 pm
by sandhya.budhi
I tried logs settings at stage level but it is not capturing the logs as expected. I reached my support team and they are checking at their end. But I worked on the error and I received response back to REST call though not successful. Waiting for the support tream to get back on the logs.