We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.

JSON Node Unexpected characters error

Comments

6 comments

  • Avatar
    Gerard Cafaro

    The API endpoint will return an HTTP status code alongside its response. The HTTP status code can be captured by specifying an output field within the HTTP node's StatusCodeOutputField property. If the API call was successful, it will return a code of 200. If it is returning an error, it will return a different code, such as 401 for unauthorized, 403 for forbidden or 500 for a generic API-side error. Specifying an output field for StatusMessageOutputField may also provide additional details for the error. Immediately after the HTTP node, you can add a Split or Filter node to separate the successful API calls.

     

    0
    Comment actions Permalink
  • Avatar
    Himangi Nashine

    Thank you Gerard Cafaro. It's a wonderful idea to add a Split or Filter node to separate the successful API calls. Also, is there any way to view the bad data with codes 401,403 0r 500 and any workaround to fix this API  error code immediately? I see we have got a combination of status code output messages of 200 & 401.

    0
    Comment actions Permalink
  • Avatar
    Gerard Cafaro

    The HTTP 401 error looks like a username and password weren't provided to the endpoint. There are several ways to authenticate an API request, and a particular API may only support a subset of ways. The two most common ways is using the ServerUsername and ServerPassword properties within the HTTP node or using header-based authentication, which has varying syntax by API endpoint. Most commonly, this is set by adding a base64 representation of "username:password" (username and password may be literal or tokens, but the semicolon is always there) and then appending that to the string "Authorization: Basic ". For example, a user "sampleuser" and password "samplepassword" would become the string below. This is then inserted into the HTTP node's header property:

    Authorization: Basic c2FtcGxldXNlcjpzYW1wbGVwYXNzd29yZA==

    Although to answer your question more generically, if the Message field doesn't give enough details, for example, it just returns "invalid syntax," then checking the API response itself may contain more details. In the screenshot above, the response is written to a file, which can be read in via a subsequent node.

     

    0
    Comment actions Permalink
  • Avatar
    Himangi Nashine

    I am not clear with the same API URL used in the HTTP node, why we got 2 different status code of 200 (good API call) and 401 (Bad request) at the same time? Also, we have used Authorization at HTTP node Header's property.

    0
    Comment actions Permalink
  • Avatar
    Gerard Cafaro

    Each record fed into the HTTP node will trigger its own API call. Does the header property come from a data flow property or a field? If it comes from a field, does the input match on all of the records? 

    0
    Comment actions Permalink
  • Avatar
    Himangi Nashine

    We got error on HTTP node now (screenshot). I also notice slow API call performance this week with all our workflows. Sorry, I was wrong for this HTTP( mobile defects node)-2nd screenshot, we aren't using Authorization. Server username and password are coming from 1 credentials node then it goes to Sign-in node (3rd screenshot).Another thing is how to improvise API call performance?

    This error of 401 or any failure gets resolved by itself when I run again after 5-10 mins, this I am not understanding.

    0
    Comment actions Permalink

Please sign in to leave a comment.