Hi
@Varma NadimpallyIf you want the body of your request to contain:
- [{"FinBankAcctNum": "1234567890"}]
- OR [{ "FinBankAcctNum": "1234567890"},{ "FinBankAcctNum": "1234567891"}]
- OR any number of {"FinBankAcctNum": ""} in the array
you would need to use the following definition in your swagger:
- name: requestBody
in: body
description: request body with all the data elements that needs to be protected
required: true
schema:
type: array
items:
type: object
required:
- FinBankAcctNum
properties:
FinBankAcctNum:
type: string
which would generate the following fields
06 ReqBody2-num PIC S9(9) COMP-5 SYNC.
06 ReqBody OCCURS 255.
09 FinBankAcctNum-length PIC S9999 COMP-5 SYNC.
09 FinBankAcctNum PIC X(255).
09 filler PIC X(1).
where ReqBody2-num indicates the number of occurrences of ReqBody, which represents a JSON object with a single mandatory field named FinBankAcctNum. And FinBankAcctNum-length represents the length of FinBankAcctNum as Sue has illustrated in her example.
I am not sure how much freedom the API's freeform format allows, but in order to build the JSON object in z/OS Connect the properties of "object" data types need to be known. Specifying the following structure:
schema:
type: array
items:
type: string.
would not help as it defines an array of strings which [{"FinBankAcctNum": "1234567890"}]
isn't.
If the format allows you to have, for instance, [{"FinBankAcctNum": "1234567890"},{"FinBankAcctNum": "1234567890","FinBankAcctType": "savings"},{"FinBankAcctType": "checking"}]
, then I would imagine that the following definition may work with z/OS Connect:
- name: requestBody
in: body
description: request body with all the data elements that needs to be protected
required: true
schema:
type: array
items:
type: object
properties:
FinBankAcctNum:
type: string
FinBankAcctType:
type: string
note that the properties are no longer required, and thus for each occurrence of the item you need to indicate if the optional fields are present. This is done by setting 1 or 0 to the *-num fields.
Regards,
------------------------------
Eric Phan
------------------------------
Original Message:
Sent: Thu October 21, 2021 12:41 PM
From: Varma Nadimpally
Subject: Need to invoke Api which has FREE FROM REQUEST BODY.
Trying to invoke an Api from Zos connect. Request and RESPONSE for the Api is Free form shown below in postman.
REQUEST BODY. Please understand this is freeform meaning ARRAY or objects can be one or more in this case i am only trying with one.
[ { "FinBankAcctNum": "1234567890"}] OR
[ { "FinBankAcctNum": "1234567890"},{ "FinBankAcctNum": "1234567890"}
]
Created Swagger with Body as below.
- name: requestBody
in: body
description: request body with all the data elements that needs to be protected
schema:
type: array
items:
type: string.
Copybook created as below.
05 ReqBody-num PIC S9999 COMP-5 SYNC.
06 ReqBody OCCURS 255.
09 ReqBody2-length PIC S9999 COMP-5 SYNC.
09 ReqBody2 PIC X(255).
Cobol program i moved the following into the this.
MOVE '[ { "FinBankAcctNum": "1234567890"}]' TO ReqBody2
Api Received the following payload.
["[ { \"FinBankAcctNum\": \"1234567890\"}]"]. extra " and [] added by zosconnect tool created ara file .... .
How can i send the PAYLOAD. Please remember the PAYLOAD is an ARRAY with freeform and i need to send that exact payload using the Zos connect end how can i do it.
------------------------------
Varma Nadimpally
------------------------------