• Benjamin Vison
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies

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?

I am trying to setup the OAuth process to get the access_token, specifically in PHP using this example (http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php). However, I don't know how to avoid the "Allow Access" page that shows up, I would like to be autimatically allowed so the application can continue and get the access_token... It would be a pain to have to manually allow access on every system I am planning on implementing this integration.. What am I missing?
I am trying to setup the OAuth process to get the access_token, specifically in PHP using this example (http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php). However, I don't know how to avoid the "Allow Access" page that shows up, I would like to be autimatically allowed so the application can continue and get the access_token... It would be a pain to have to manually allow access on every system I am planning on implementing this integration.. What am I missing?