none
BizTalk - Json response from a rest service

    Question

  • From biztalk , I am trying to connect to a REST service which accepts json req and sending a json response.

    I am able to send to json req to the service and when the response comes in to biztalk, I got the following error.

    Source: "JSON decoder" Receive Port: testrest  URI: xxxx "" Reason: XmlNodeConverter can only convert JSON that begins with an object.

    the service response is having array of objects in it. so i understand the above error is thrown.

    I found the below link and created a pipeline component to fix this issue

    http://biztalk.stottcreations.com/2016/05/error-in-json-instance-file-xmlnodeconverter-can-only-convert-json-that-begins-with-an-object

    But i am getting the below error now


    There was a failure executing the receive pipeline: "bttest.RecJsonResp, bttest.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6c68eaf68da2c621" Source: "JSON decoder" Receive Port: "testw1" URI: "D:\wqin\*.*" Reason: Invalid property identifier character: “. Path '', line 1, position 1.

    then i have tried changing

    from {{“{0}”:{1}}} to {{&quot{0}&quot:{1}}}, even then i got the below error There was a failure executing the receive pipeline: "bttest.RecJsonResp, bttest.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6c68eaf68da2c621" Source: "JSON decoder" Receive Port: "testw1" URI: "D:\wqin\*.*" Reason: Invalid property identifier character: &. Path '', line 1, position 1.

    Any help to resolve this issue. ? or any other way to resolve my main issue ?


    • Edited by BTSSVR Wednesday, March 15, 2017 6:35 AM
    Monday, March 13, 2017 6:47 AM

Answers

  • Hi,

    Please cross verify the character that you are using.

    - The reference site has invalid character quotes mentioned ie {{“{0}”:{1}}}

    - The valid c# character for double quotes is {{"{0}":{1}}}

    Give a try it should work.

    Thanks,

    Vikas K

    • Marked as answer by BTSSVR Friday, March 17, 2017 3:51 AM
    Friday, March 17, 2017 2:49 AM
    Answerer

All replies

  • If you look at the code, you see that it has to be {{“{0}”:{1}}}, since its a formatting string.

    Did you add that string to the resource file and fill in the rootnode value at the pipeline properties (in the example it has the value List)?

    Tuesday, March 14, 2017 8:52 PM
  • Hi Rex, i added the string {{“{0}”:{1}}} to the resource file as mentioned in the link. But in runtime, i am getting the below error in JSON Decoder

    http://biztalk.stottcreations.com/2016/05/error-in-json-instance-file-xmlnodeconverter-can-only-convert-json-that-begins-with-an-object

    There was a failure executing the receive pipeline: "bttest.RecJsonResp, bttest.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6c68eaf68da2c621" Source: "JSON decoder" Receive Port: "testw1" URI: "D:\wqin\*.*" Reason: Invalid property identifier character: “. Path '', line 1, position 1.

    Wednesday, March 15, 2017 6:34 AM
  • Then I should write an unittest for the pipeline component and examine the output.

    I use always use the winterdom pipelinetesting library for that, see https://www.nuget.org/packages/Winterdom.BizTalk.PipelineTesting/

    Wednesday, March 15, 2017 8:43 AM
  • Hi,

    Please cross verify the character that you are using.

    - The reference site has invalid character quotes mentioned ie {{“{0}”:{1}}}

    - The valid c# character for double quotes is {{"{0}":{1}}}

    Give a try it should work.

    Thanks,

    Vikas K

    • Marked as answer by BTSSVR Friday, March 17, 2017 3:51 AM
    Friday, March 17, 2017 2:49 AM
    Answerer
  • Can you share a sample response? Your response might be different from the link sample response.
    Friday, March 17, 2017 3:27 AM
  • Thanks SMS. The problem was with the double quotes only.

    It worked now, after i changed the double quotes as you suggested.



    • Edited by BTSSVR Friday, March 17, 2017 3:53 AM
    Friday, March 17, 2017 3:53 AM