0
votes

I have a requirement to import custom data into Acumatica using web service using web service.

I have created a custom table having 2 string field and one ntext field which will hold XML data. Created a GI for it and exposed in web service endpoint.

The import JSON Data format is like this.

    [
  {
    "OrderNbr": "1",
    "CommandValue": "8",
    "Xmldata": "<?xml version=\"1.0\" encoding=\"utf-8\"?><MLW Cmd=\"8\" TStamp=\"2018-12-21T11:38:25\" Id=\"dsgx1\" OrgId=\"157035408\" DevId=\"b9d863ca-REG-4825e4aa-566b5fc7\" RouteId=\"Resource-879-1\" StopId=\"Location230\" LocationKey=\"Location230\" StopType=\"67\"> <GPS Altitude=\"278.46383285522461\" Latitude=\"34.0487467032243\" Longitude=\"-84.673757432107507\" NoOfSat=\"7\" Speed=\"1.3679999828338623\" SatTStamp=\"2018-12-21T11:37:26\" Direction=\"0\" FixQuality=\"A\" /> <FieldData LCode=\"1\" OwnerId=\"Location230\"> <Field FId=\"89815\" Value=\"No\" /> <Field FId=\"89817\" Value=\"No\" /> <Field FId=\"89816\" Value=\"Patrick N\" /> </FieldData> <Job Id=\"Order-878-4\" Status=\"4\"> <Item Status=\"4\" Id=\"TIFTUF\" Mode=\"Manual\" /> </Job></MLW>"
  }
]

I have tried in POSTMAN using basic authentication.

I am getting following error

PUT: 400 Bad request GET: 500 Internal server error.

UPDATE: I have created a custom list page and configured it in the endpoint.

I have tested in POSTMAN and

Following are the endpoint and the JSON string used to create records

http://localhost/XYZ/(W(3))/entity/XYZ/17.200.001.001/MyResposeImport



{
    "OrderNbr": {value :"b"},
    "CommandValue": {value :"8"},
    "Xmldata": {value :"<?xml version='1.0' encoding='utf-8'?><MLW Cmd='8' TStamp='2018-12-21T11:38:25' Id='dsgx1' OrgId='157035408' DevId='b9d863ca-REG-4825e4aa-566b5fc7' RouteId='Resource-879-1' StopId='Location230' LocationKey='Location230' StopType='67'> <GPS Altitude='278.46383285522461' Latitude='34.0487467032243' Longitude='-84.673757432107507' NoOfSat='7' Speed='1.3679999828338623' SatTStamp='2018-12-21T11:37:26' Direction='0' FixQuality='A' /> <FieldData LCode='1' OwnerId='Location230'> <Field FId='89815' Value='No' /> <Field FId='89817' Value='No' /> <Field FId='89816' Value='Patrick N' /> </FieldData> <Job Id='Order-878-4' Status='4'> <Item Status='4' Id='TIFTUF' Mode='Manual' /> </Job></MLW>"}
  }

PUT Returns back OK and the response give below

{
    "id": "94a00013-37bf-4077-bfb6-2e8662988547",
    "rowNumber": 1,
    "note": null,
    "OrderNbr": {
        "value": "b"
    },
    "ShippingStatus": {},
    "XMLData": {},
    "custom": {},
    "files": []
}

I have checked in the back end and no record added to the table.

I have created the sitemap under the hidden section since the screen is only API call.

What may be the reason for the record not added to the table?

1
Generic Inquiries are inquiries, they are for getting data out of the system, not importing it.Serg Rogovtsev

1 Answers

0
votes

I have solved the Issue. The JSON Data field name is different from DAC label and API is look DAC label not the field name.

I have changed the JSON data to following and it works fine

{
    "OrderNbr": {value :"b"},
    "ShippingStatus": {value :"8"},
    "XMLData": {value :"<?xml version='1.0' encoding='utf-8'?><MLW Cmd='8' TStamp='2018-12-21T11:38:25' Id='dsgx1' OrgId='157035408' DevId='b9d863ca-REG-4825e4aa-566b5fc7' RouteId='Resource-879-1' StopId='Location230' LocationKey='Location230' StopType='67'> <GPS Altitude='278.46383285522461' Latitude='34.0487467032243' Longitude='-84.673757432107507' NoOfSat='7' Speed='1.3679999828338623' SatTStamp='2018-12-21T11:37:26' Direction='0' FixQuality='A' /> <FieldData LCode='1' OwnerId='Location230'> <Field FId='89815' Value='No' /> <Field FId='89817' Value='No' /> <Field FId='89816' Value='Patrick N' /> </FieldData> <Job Id='Order-878-4' Status='4'> <Item Status='4' Id='TIFTUF' Mode='Manual' /> </Job></MLW>"}
  }