The avalara JSON request not working using PHP cURL but working in postman

103 views Asked by At

I have created a JSON for avalara request, line items are 10 in count. But it is always showing error as -

code:ErrorCountLimitExceededError number:1722 message : The request has exceeded the maximum number of validation errors.

When I reduce the line item to count 6, it works fine. but my requirement is more than that. The same JSON is working fine in postman.

Following is the JSON which I had used-

{
    "lines": [
        {
            "number": "1",
            "quantity": 1,
            "amount": 100,
            "taxCode": "PS081282",
            "itemCode": "Y0001GHGH",
            "description": "TEST"
        },
        {
            "number": "2",
            "quantity": 1,
            "amount": 100,
            "taxCode": "PS081282A",
            "itemCode": "TTTTYYYA",
            "description": "TEST"
        },
        {
            "number": "3",
            "quantity": 1,
            "amount": 190,
            "taxCode": "PS081282B",
            "itemCode": "HGHGHG0001B",
            "description": "TEST"
        },
        {
            "number": "4",
            "quantity": 1,
            "amount": 2300,
            "taxCode": "PS081282C",
            "itemCode": "PKOO0001C",
            "description": "TEST"
        },
        {
            "number": "5",
            "quantity": 1,
            "amount": 200,
            "taxCode": "PS081282D",
            "itemCode": "ABCF567",
            "description": "TEST"
        },
        {
            "number": "6",
            "quantity": 1,
            "amount": 10990,
            "taxCode": "PS081282E",
            "itemCode": "Y00DSD01E",
            "description": "TEST"
        },
        {
            "number": "7",
            "quantity": 1,
            "amount": 140,
            "taxCode": "PS081282F",
            "itemCode": "Y00GJG232",
            "description": "TEST"
        },
        {
            "number": "8",
            "quantity": 1,
            "amount": 100,
            "taxCode": "PS081282F2X",
            "itemCode": "65HGFH675",
            "description": "TEST"
        }
    ],
    "type": "SalesInvoice",
    "companyCode": "DEFAULT",
    "date": "2023-01-10",
    "customerCode": "ABC",
    "purchaseOrderNo": "2023-01-10-001",
    "addresses": {
        "singleLocation": {
            "line1": "2000 Main Street",
            "city": "Irvine",
            "region": "CA",
            "country": "US",
            "postalCode": "92614"
        }
    },
    "commit": true,
    "currencyCode": "USD",
    "description": "Yarn"
}
1

There are 1 answers

1
Blake Smerdon On

I just ran into this issue. The call was throwing errors if the body was over 2048 characters. I added a header "Content-Length: strlen($data)" where $data is your POST data and that fixed the problem. Also, I specified content-type to application/json. Just to be safe.

Hope that helps.