Sudden issues with Opportunity API

My company has been using the API to take form information collected through our website and creating a new Opportunity. Up until the last 2-3 weeks everything was working fine. Now we are getting errors. Has something recently changed with the API? Below is (first) the data we are sending and (second) the response we are getting back. Any help would be GREATLY appreciated!

 

{"OPPORTUNITY_NAME":"Test Co","OPPORTUNITY_STATE":"Open","VISIBLE_TO":"TEAM","VISIBLE_TEAM_ID":"1779766","TAGS":[{"TAG_NAME":"Request a Quote Form"}],"CATEGORY_ID":"47581","PIPELINE_ID":"47581","STAGE_ID":"632241","OPPORTUNITY_DETAILS":"as ,lefrpo eprap[asd sdf ","LINKS":[{"CONTACT_ID":225445265}],"CUSTOMFIELDS":{"0":{"CUSTOM_FIELD_ID":"OPPORTUNITY_FIELD_12","FIELD_VALUE":"Spring 2017"},"1":{"CUSTOM_FIELD_ID":"OPPORTUNITY_FIELD_6","FIELD_VALUE":"apsmdfa mefam fm;fpm as;df"},"2":{"CUSTOM_FIELD_ID":"OPPORTUNITY_FIELD_3","FIELD_VALUE":"5058209357"},"3":{"CUSTOM_FIELD_ID":"OPPORTUNITY_FIELD_1","FIELD_VALUE":"Internet Search or Directory"},"5":{"CUSTOM_FIELD_ID":"OPPORTUNITY_FIELD_7","FIELD_VALUE":true},"10":{"CUSTOM_FIELD_ID":"OPPORTUNITY_FIELD_14","FIELD_VALUE":true},"14":{"CUSTOM_FIELD_ID":"OPPORTUNITY_FIELD_18","FIELD_VALUE":true},"15":{"CUSTOM_FIELD_ID":"OPPORTUNITY_FIELD_19","FIELD_VALUE":true}}}

array(1) {
  [0]=>
  object(stdClass)#235 (2) {
    ["Name"]=>
    string(29) "apiOpportunity.CUSTOMFIELDS.0"
    ["Message"]=>
    string(658) "Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Insightly.App.Api.Areas.v21.Models.APICustomField]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'CUSTOMFIELDS.0', line 1, position 319."
  }
}
0

Comments

6 comments
  • Hi Jennifer,

    I have looked at your JSON Payload and i see 2 issues:


    1. Tag Name should not have spaces

    2. Custom Field is not a proper collection

     

    Please try the payload i have fixed below and let me know if it works. I have tried it on my end and got a successful response

     

    {
    "OPPORTUNITY_NAME": "Test Co",
    "OPPORTUNITY_STATE": "Open",
    "VISIBLE_TO": "TEAM",
    "VISIBLE_TEAM_ID": "1779766",
    "TAGS": [
    {
    "TAG_NAME": "RequestaQuoteForm"
    }
    ],
    "CATEGORY_ID": "47581",
    "PIPELINE_ID": "47581",
    "STAGE_ID": "632241",
    "OPPORTUNITY_DETAILS": "as ,lefrpo eprap[asd sdf ",
    "LINKS": [
    {
    "CONTACT_ID": 225445265
    }
    ],
    "CUSTOMFIELDS": [
    {
    "CUSTOM_FIELD_ID": "OPPORTUNITY_FIELD_12",
    "FIELD_VALUE": "Spring 2017"
    },
    {
    "CUSTOM_FIELD_ID": "OPPORTUNITY_FIELD_6",
    "FIELD_VALUE": "apsmdfa mefam fm;fpm as;df"
    },
    {
    "CUSTOM_FIELD_ID": "OPPORTUNITY_FIELD_3",
    "FIELD_VALUE": "5058209357"
    },
    {
    "CUSTOM_FIELD_ID": "OPPORTUNITY_FIELD_1",
    "FIELD_VALUE": "Internet Search or Directory"
    },
    {
    "CUSTOM_FIELD_ID": "OPPORTUNITY_FIELD_7",
    "FIELD_VALUE": true
    },
    {
    "CUSTOM_FIELD_ID": "OPPORTUNITY_FIELD_14",
    "FIELD_VALUE": true
    },
    {
    "CUSTOM_FIELD_ID": "OPPORTUNITY_FIELD_18",
    "FIELD_VALUE": true
    },
    {
    "CUSTOM_FIELD_ID": "OPPORTUNITY_FIELD_19",
    "FIELD_VALUE": true
    }
    ]
    }

     

     

    Thank you for using Insightly!

    Engineering

    0
    Comment actions Permalink
  •  

    I am not sure what you mean by "Custom Field is not a proper collection"

    0
    Comment actions Permalink
  • Hi Jennifer,

    What i mean is the our JSON Parser is having problems with the payload you sent. Did you get a chance to try the adjusted one i sent in my previous comment?

     

    Engineering

    0
    Comment actions Permalink
  • I did and I am getting the same result.

    0
    Comment actions Permalink
  • Hi Jennifer,

    Could you please provide the updated payload you are sending to the API so we can see where the problem lies? The error you described normally occurs when the square brackets are missing from the custom fields collection.

    Thank you

    0
    Comment actions Permalink
  •  

    I think I have solved my problem and it appears that it was a code issue on my end. Thanks for your help

    0
    Comment actions Permalink

Please sign in to leave a comment.