+ Start a Discussion
Fabio Andree Scheurel MWFabio Andree Scheurel MW 

Bug in Tooling API when assigning picklist values to record types

I found a bug in the Tooling API, but cannot report it directly to Salesforce.

We are using the Tooling API to assign new picklist values to record types. This is a typical request that we send:

URL: https://SANDBOX.cs80.salesforce.com/services/data/v39.0/tooling/sobjects/RecordType/012250000008wmq
Payload:
{
  "Metadata": {
    "active": true,
    "compactLayoutAssignment": "Master_Product_Compact_Layout",
    "description": "Master Product, managed in MDM.",
    "label": "Master Product",
    "picklistValues": [
      {
        "picklist": "Packaging__c",
        "values": [
          {
            "default": false,
            "valueName": "twinpack, 1 ltr. + 1 ltr."
          }
        ]
      }
    ]
  },
  "FullName": "Product2.Master_Product"
}
Error Message:
{
    "statusCode": 400,
    "headers": {
        "Pragma": "no-cache",
        "Cache-Control": "no-cache",
        "Date": "Wed, 01 Mar 2017 14:27:59 GMT",
        "Server": "Microsoft-IIS/8.0",
        "X-AspNet-Version": "4.0.30319",
        "X-Powered-By": "ASP.NET",
        "Content-Length": "151",
        "Content-Type": "text/plain; charset=utf-8",
        "Expires": "-1"
    },
    "body": "[{\"message\":\"Picklist value: twinpack%2C 1 ltr%2E   1 ltr%2E in picklist: Packaging__c not found\",\"errorCode\":\"FIELD_INTEGRITY_EXCEPTION\",\"fields\":[]}]"
}

This error only occurs for picklist values that have a "+" character in their name. The Tooling API seems to URL decode the request where "+" characters are replaced with a space, as you can see in the error message. Additional URL encoding of the valueName won't help. This seems to be an error of the RecordType Tooling API, as inserting new picklist values with a "+" character does work fine.