Hi,
I used the screen “Web Services Endpoints” then menu “… > Service Definition > Open API 2.0” to generate the swagger.json file.
This is for the Acumatica: "/entity/Default/23.200.001" collection
I then processed that through the openapi-generator to generate a java client:
java -jar openapi-generator-cli-7.8.0.jar generate -i [domain]entity/Default/23.200.001/swagger.json?company=[company] -g java --api-package [mypackage].finance.acumatica.openapi.client --model-package [mypackage].acumatica.openapi.client.model -o testoutput --skip-validate-spec
That generates the java client .java files. These all compile to .class files without any errors.
So this all looks good so far. This is industry standard for generating a client from swagger.json data.
However when I run the client I get an error. The client makes a request to acumatica for data like:
VendorApi va = new VendorApi(apiClient);
List ids = new ArrayList();
ids.add("V00002");
Vendor vendor = va.vendorGetByKeys(ids, null, null, null, null);
However the call to vendorGetByKeys fails with an error:
The field `_links` in the JSON string is not defined in the `Vendor` properties. JSON: {"id":"e82950d0-11f2-ee11-835e-02e72c89c05e","rowNumber":1,"note":{"value":""},"AccountRef":{},
…[a whole bunch more JSON of the Vendor record that I cut out for brevity]...
"_links":{"self":"/entity/Default/23.200.001/Vendor/e82950d0-11f2-ee11-835e-02e72c89c05e","files:put":"/entity/Default/23.200.001/files/PX.Objects.AP.VendorMaint/BAccount/e82950d0-11f2-ee11-835e-02e72c89c05e/{filename}"}}
Basically the “links” tag, at the very end of the Vendor record is not expected as per the swagger.json file. However it is returned by the acumatica webservice end point.
So basically the API swagger.json specification says one format (no “links” data) and the actual returned JSON from acumatica is a different format (with the “links” data).
Is there a reason for this?
How can this be resolved?
Please let me know.
Thanks
Alex.