Custom Field PUT not working

I have not been using v2.2 for two months, but when I started again last night, code that was working a few months ago is not working.  The code is using PUT to update custom fields.
 
I GET an opportunity and then try to update a Custom Field value with PUT.
 
Below is the error and my code.  Please help!
Request failed for https://api.insight.ly/v2.2/Opportunities/9931441/CustomFields returned code 400. Truncated server response: [{"Name":"apiCustomField","Message":"Unexpected character encountered while parsing value: %. Path '', line 0, position 0."}] (use muteHttpExceptions option to examine full response) (line 96, file "Code")
 
Here is my code:
var data = {
      "CUSTOM_FIELD_ID": "",
      "FIELD_VALUE": 1
      };
 
data["CUSTOM_FIELD_ID"] =response.CUSTOMFIELDS[x].CUSTOM_FIELD_ID;
data["FIELD_VALUE"] = 0;
 
Printout of data:
 {CUSTOM_FIELD_ID=OPPORTUNITY_FIELD_1, FIELD_VALUE=0.0}
 
endp  = "/v2.2/Opportunities/9931441/CustomFields";
 
 
function connectToInsightlyPut(endp, data) {
 
  var key = "xyz";
  var api = "https://api.insight.ly" + endp;
 
  var response = UrlFetchApp.fetch(api,{
    muteHTTPexceptions : false,
    method : "PUT",
    payload : data,
    
    headers: {
      'Authorization': 'Basic ' + Utilities.base64Encode(key),
      'Content-Type': 'application/json'
    }
  
  })
   
}
0

Comments

7 comments
  • Official comment

    Hi Brett,

    We just pushed a build to production that validates custom field values for boolean fields. The endpoint is expecting true or false as a value. Previously, it was allowing invalid values through which was causing the web UI to display these incorrectly.

    Thanks,

    Brian McConnell

    Insightly Engineering Team

    Comment actions Permalink
  • Brian,

     

    The field is a numeric field not a boolean.  What else can I try?

     

    Brett

    0
    Comment actions Permalink
  • Hi Brett,

    Can you try making this request using the Postman extension for Chrome (just want to eliminate the possibility that the client library is the culprit here). 

    Thanks,

    Brian

    0
    Comment actions Permalink
  • Hi Brian, I have Brett's response:

    "The Postman extension is checked and I have been using it."

    Just a reminder that you must be in the community to leave a comment. Please do not reply to the email notification because your comment will not get posted -- and that's the only way we can continue helping you! Thanks! 

     

     

    0
    Comment actions Permalink
  • Hi Brett,

    We are aware of a recent issue with PUT operations on custom fields failing (this started shortly after we applied a bug fix for a related issue). If you can send me a screen shot of the request and response in Postman that would be great (if you can do this via a support ticket, and ask for support to forward it to me, I'll look into this asap.

    Thanks,

    Brian McConnell

    Insightly Engineering Team

    0
    Comment actions Permalink
  • Hello Brian, I believe I have encountered a similar issue with the PUT operation on custom fields. I am using Postman. Please see screenshot attached for body sent and error receivied.

    0
    Comment actions Permalink
  • Hi Rachel,

     

    As far as I can see the error is caused by an incorrect Content-Type (you have 'Text' selected). Please try the same request again but with Content-Type header set to 'application/json'. The current version of the API does not generate a correct error for a wrong content type. We are planning to fix that.

     

    Best,

    Evgeny

    0
    Comment actions Permalink

Please sign in to leave a comment.