TheGrinder
TheGrinder

Reputation: 38

Issues with Acumatica REST Contract-Based API SalesInvoice Entity 18.200.001

Automating creation of Sales Invoice via Rest API Unable to get CustomerLocation to populate

In the WebService EndPoint the Mapped Object and Mapped Fields are blank for this item

Has any one successfully used this API to modify Location? Does any one know if I have a formatting error in my JSON for Linked Entities, it matches the documentation but may not be up to date?

Tried several formats of JSON based on the guide and experience including Linked, Summary, Custom and Detail

Tried both BillToSettings and BillingSetting Entities

Searched Known issues, Newton JSon


  "Type": { "value": "Invoice" },
  "CustomerID": { "value": "C0004055" },
  /// bit does not create in Acumatica
  "BillToSettings": { "CustomerLocation": { "value": "67217" } },
  /// "BillingSettings" : {"CustomerLocation" : {"value" : "67217"}
  /// also LocationID, CustomerLocationID and many combinations there of
  "CustomerOrder": { "value": 1942 },
  "Date": { "value": "2/14/2019" },
  "Description": { "value": "SO S048773" },
  "Details": [
    {
      "InventoryID": { "value": "POLLING-HOSTING" },
      "TransactionDescr": { "value": "GPRS Monitoring" },
      "UOM": { "value": "PNTS" },
      "Qty": { "value": "3" },
      "UnitPrice": { "value": "68.25" }
    },
    {
      "InventoryID": { "value": "AIRTIME" },
      "TransactionDescr": { "value": "GPRS Airtime" },
      "UOM": { "value": "EACH" },
      "Qty": { "value": "3" },
      "UnitPrice": { "value": "20" }
    }
  ]

I expect the Default MAIN location to be overridden with 67217 instead every record shows main If I add the address Override fields (as below) then I get data for them on the successful creation of the invoice but no CustomerLocation data is returned. Nor does the LocationID update correctly

BillingSettings = new
                {
                    BillToAddressOverride = new {value = true},
                    BillToContactOverride = new { value = true },
                    CustomerLocation = new { value = "67217"}
                },

Upvotes: 0

Views: 480

Answers (1)

I tried to use your JSON example on a clean SalesDemo install of 2019R1 and could replicate the same issue that you're experiencing.

I think it has to do with the CustomerLocation field not being mapped in the Default 18.200.001 endpoint. It actually makes sense if we look at the response object - there is no CustomerLocation field in the response either.

First Attempt, without extending the API endpoint:

{
   "Type": {
      "value": "Invoice"
   },
   "CustomerID": {
      "value": "ABARTENDE"
   },
   "Date": {
      "value": "5/10/2019"
   },
   "Description": {
      "value": "Test SalesInvoice Creation"
   },
   "BillingSettings" : {
        "CustomerLocation" : {
            "value" : "VEGAS"
        }
   }
}

Response from the first attempt:

"BillingSettings": {
    "BillToAddress": {
        "AddressLine1": {
            "value": "201 Lower Notch Rd"
        },
        "AddressLine2": {},
        "City": {
            "value": "Little Falls"
        },
        "Country": {
            "value": "US"
        },
        "PostalCode": {
            "value": "07424"
        },
        "State": {
            "value": "NJ"
        }
    },
    "BillToAddressOverride": {
        "value": false
    },
    "BillToContact": {
        "Attention": {
            "value": "Accounts Receivable"
        },
        "BusinessName": {
            "value": "USA Bartending School"
        },
        "Email": {
            "value": "[email protected]"
        },
        "Phone1": {
            "value": "+1 (908) 532-9522"
        }
    },
    "BillToContactOverride": {
        "value": false
    }
}

If you extend the endpoint and implement the Location field which can be found under the Invoice Summary selection when populating the field, you should be able to achieve your intended outcome. PS. I added the Location on the SalesInvoice object itself, and not on the BillingSettings object:

Adding the Location field

Second Request, the extended endpoint includes the Location field that was added:

{
   "Type": {
      "value": "Invoice"
   },
   "CustomerID": {
      "value": "ABARTENDE"
   },
   "Date": {
      "value": "5/10/2019"
   },
   "Description": {
      "value": "Test SalesInvoice Creation"
   },
   "Location" : {
        "value" : "VEGAS"
    }
}

Second Response:

{
    "Amount": {
        "value": 0
    },
    "Balance": {
        "value": 0
    },
    "BillingSettings": {
        "BillToAddressOverride": {
            "value": false
        },
        "BillToContactOverride": {
            "value": false
        }
    },
    "Currency": {
        "value": "USD"
    },
    "CustomerID": {
        "value": "ABARTENDE"
    },
    "Date": {
        "value": "2019-05-10T00:00:00+00:00"
    },
    "Description": {
        "value": "Test SalesInvoice Creation"
    },
    "DueDate": {
        "value": "2019-06-09T00:00:00+02:00"
    },
    "Hold": {
        "value": false
    },
    "Location": {
        "value": "VEGAS"
    },
    "ReferenceNbr": {
        "value": "AR006994"
    },
    "Status": {
        "value": "Balanced"
    },
    "Type": {
        "value": "Invoice"
    }
}

As to whether the CustomerLocation holds any meaningful value/purpose, I'm not sure, so I left it in the BillingSettings as is.

Upvotes: 2

Related Questions