+ Start a Discussion
Net Tech InternationalNet Tech International 

Error Create/Update records with one-to-many relationship REST API

I am working on integrating a system with Salesforce through the REST Api and I am having some issues with relationships. I was able to create the following structure in salesforce 

Opportunity
    ... Standard Fields...
    OpportunityTags__r (onetomany relationship to a custom product)

OpportunityTag
    - TagName
    - TagNumber

The problem that I am having is when I try to create/update a new Opportunity via REST including the OpportunityTags... I am sending the following JSON:

{
    "ownerId": "[OppOwnerId]",
    "AccountId": "[OppAccountId]",
    "CloseDate": "2016-08-16",
    "Name": "[NameOfOp]",
    "StageName": "Prospecting",
    "Opportunity_Tags__r": [
      {
        "TagName__c": "[TagName]",
        "TagNumber__c": "[##]"
      },
      ....
    ]
}

I have confirmed that I can retrieve the Opportunity and its Tags using the sub-select (SELECT [fields] FROM Opportunity_Tags__r) so the relationship is there and it's working. The problem that I get when I send that REST I get the following error:

"[{"message":"QueryResult must start with '{'","errorCode":"JSON_PARSER_ERROR"}]"

If I remove the Opportunity_Tags__r portion of the JSON the opportunity gets normally created.

What am I missing in order to create/update objects with an array of childs included?