Malformed JSON when calling API from JAVA

766 views Asked by At

I'd like to thank anyone for their response a head of time.

I'm getting the below error when calling a AVALARA API from a Java application.

{"ResultCode": "Error","Messages": [{"Summary": "Malformed JSON near 'ProcessCode' : [Field \"ProcessCode\" is not recognized]","Severity": "Error","Source": "Avalara.Web.REST"}]}  

Passing the below. ProcessCode is a required field for this API. I feel like I must be missing something simple. I'm not a Java expert, nor an expert with JSON, so I'm kind of lost at this point. Any ideas?

[
    {
        "ProcessCode" : "1", 
        "DocCode" : "1234", 
        "DocType" : "1", 
        "DocDate" : "09/05/2013",
        "CustomerCode" : "11111111",
        "LineNo" : "1",
        "Amount" : "100",
        "DestRegion" : "US",
        "DestPostalCode" : "12345",
        "OrigRegion" : "US",
        "OrigPostalCode" :"12345"
    }
]  
1

There are 1 answers

0
Chris Gerken On

You're passing a JSON array (square brackets), try sending just a single JSON object (no square brackets)