• Sankalita Chatterjee 19
  • 5 Points
  • Member since 2017

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 2
I have been trying to create CurrencyType records from APEX and since that doesn't support DML, have been using the REST endpoint and POST method. Everything work fine with single record but with multiple records, I am getting this error:
[ { "message": "Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row", "errorCode": "INVALID_FIELD" } ]

I don't see how the code worked for single object, if it really were an Invalid Field.
I have seen couple of related posts but have been unable to fix my issue.

Here is my code:
public static void syncCurrencyTypeTableMultiple(){

 Http h = new Http(); 
HttpRequest req = new HttpRequest(); 

req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v41.0/sobjects/CurrencyType/'); 
req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId()); 
req.setHeader('Content-Type', 'application/json'); 

List<CurrencyType> currTypeList = new List<CurrencyType>(); 

for(sanmgdpack__PST_Currency__c curr: [Select sanmgdpack__ISO_Code__c, sanmgdpack__Conversion_Rate__c, sanmgdpack__Decimal_Places__c FROM sanmgdpack__PST_Currency__c]) { 
CurrencyType currTypeObj = new CurrencyType( IsoCode = curr.sanmgdpack__ISO_Code__c, ConversionRate = curr.sanmgdpack__Conversion_Rate__c, DecimalPlaces = Integer.valueOf(curr.sanmgdpack__Decimal_Places__c) ); currTypeList.add(currTypeObj); 
String jsonStr = JSON.serializePretty(currTypeList); 
System.debug('json Str:' + jsonStr); 

//test //List<CurrencyType> deserList = (List<CurrencyType>)JSON.deserialize(jsonStr, List<CurrencyType>.class); 
//System.debug('deserlist::::' + deserList); //works fine 

HttpResponse res = h.send(req); 


On my developer edition I am able to use the /services/data/v38.0/composite composite API. I seriously LOVE this API, it cuts down on network time and makes life easy.

There is problem however, recently I was trying to integrate with a new customer and to my surprise the composite REST endpoint was 404 not found. The response from SFDC was:

    "errorCode": "NOT_FOUND",
    "message": "The requested resource does not exist"
Other REST requests on this domain with the same authentication work great... I thought that the composite API was Generally Available. Any ideas? Thanks in advance for the help.



is there a way to authenticate an application for using the salesforce rest api with just the normal username / password credentials from

the basic http authentication?

I know thats not safe but its just for testing the functionality of my application.


best regards


  • June 27, 2012
  • Like
  • 0