Hi Colin,
That documentation is correct, but as mentioned above, it is in the section of the Knowledge Center related to building a MQ service provider service using the command line build toolkit, which produces different request and response schemas.
"For compatibility with earlier releases, MQ service provider services can also be created using the command line build toolkit, but these do not benefit from the additional functionality provided by the API Toolkit. It looks like you may have been using request payload from "Test the stock query service", which is only applicable to its preceding Knowledge Center pages for creating the stock query service using the build toolkit and a properties file."
However, I believe you are using a service built using the API Toolkit, either from the sample server template sampleMqStockManager or by following the Quick Start scenario Quick Start scenario instructions Create a two-way IBM MQ service. Which uses the JSON syntax, I provided above.
Regards, Sue
------------------------------
Sue Bayliss
IBM z/OS Connect EE
------------------------------
Original Message:
Sent: Thu October 01, 2020 10:44 AM
From: Colin Paice
Subject: Strange message from the stock query service
The documentation
https://www.ibm.com/support/knowledgecenter/SS4SVW_beta/reference/mq_test_service.html
says
curl -i -k -X POST http://host:port/zosConnect/services/stockQuery?action=invoke --data "{\"STOCKQRYOperation\": { \"sqreq\": { \"item_id\": 2033 }}}" -H "Content-Type:application/json"
which is different to what you suggest - should the doc be updated?
------------------------------
Colin Paice
Original Message:
Sent: Wed September 23, 2020 03:26 AM
From: Sue BAYLISS
Subject: Strange message from the stock query service
Hi Colin,
--data '{ "SQREQ": { "ITEM_ID": 2033 }}' will work.
But the case of the JSON field names is significant, in this example, uppercase. The request data must match what is expected by the service request schema.
You can view the request schema for a service using the URI: /zosConnect/services/{serviceName}/schema/request as documented in Get the request schema of a service.
I agree that surrounding the data string with single quotes and avoiding the need to escape double quotes is neater, (personally I had enclosed the data string value in double quotes and so had to escape the double quotes within the string).
Regards, Sue
------------------------------
Sue Bayliss
IBM z/OS Connect EE
Original Message:
Sent: Wed September 23, 2020 03:01 AM
From: Colin Paice
Subject: Strange message from the stock query service
Sue,
Are you saying
replace
--data '{"STOCKQRYOperation": {"sqreq" : { "item_id": 2033}}}'
with
--data '{"sqreq" : { "item_id": 2033}}'
By putting the request inside single quotes I do not need to escape the double quote within the payload.
Or do I need to escape the double quotes anyway... for the z/OS connect processing?
regards
Colin
Original Message:
Sent: 9/22/2020 5:39:00 AM
From: Sue BAYLISS
Subject: RE: Strange message from the stock query service
Hi Colin,
This problem is caused by the request payload being sent to the service not matching the JSON schema that the service expects.
If you are using the MQ service provider sample stockQuery.sar file shipped with the sample server template sampleMqStockManager, change the payload you send on the --data argument to be:
"{\"SQREQ\": {\"ITEM_ID\": 2033 }}"
This should receive the response:
{"SQRESP":{"ITEM_ID":2033,"ITEM_DESC":"A description.","ITEM_COST":4,"ITEM_COUNT":500}}
The API Toolkit supports the creation of services (.sar files) which use the MQ service provider. This is the typical approach to create these services, and is how the sample stockQuery.sar file was created. Instructions for using the API Toolkit to create services for the MQ service provider is described in the Quick Start scenario instructions Create a two-way IBM MQ service and more generally in Creating a CICS, IMS or IBM MQ service.
For compatibility with earlier releases, MQ service provider services can also be created using the command line build toolkit, but these do not benefit from the additional functionality provided by the API Toolkit. It looks like you may have been using request payload from "Test the stock query service", which is only applicable to its preceding Knowledge Center pages for creating the stock query service using the build toolkit and a properties file.
Regards, Sue
------------------------------
Sue Bayliss
IBM z/OS Connect EE
Original Message:
Sent: Sun September 20, 2020 02:02 PM
From: Colin Paice
Subject: Strange message from the stock query service
and getting back
{"SQRESP":{"ITEM_ID":104523,"ITEM_DESC":"ription. 00050000000","ITEM_COST":null,"ITEM_COUNT":45}}
which
a) does not match the 2033 .. it comes back 104523
b) there is a strand ription.005.... with a new line in the middle and I was expecting a cost
regards
Colin