• Navya Veeraswamy
  • NEWBIE
  • 0 Points
  • Member since 2023

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

Error: [
    {
        "errorCode": "NOT_FOUND",
        "message": "The requested resource does not exist"
    }
]

Curl:

curl --location --request POST 'https://xyzsolutions7-dev-ed.develop.my.salesforce.com/services/data/v50.0/sobjects/Opportunity/' \
--header 'Authorization: Bearer 00D5h000008Nj5y!ARkAQDD7JVaKTCHHT.dHTnOIUN680XIfXgzvYr3HqVGz7yu5OZWATT9HqljfV5cHHi355tbTNuOrmomzo3Tm1dUY2S_CGAi.' \
--header 'Content-Type: application/json' \
--header 'Cookie: BrowserId=U-v_xWGkEe64ePPDdIi5iA; CookieConsentPolicy=0:1; LSKey-c$CookieConsentPolicy=0:1' \
--data-raw '{
    "Name": "Sample Opportunity",
    "AccountId": "0015h00001UePQgAAN",
    "StageName": "Prospecting",
    "Amount": 10000,
    "CloseDate": "2023-12-06"
}'

 

While trying to create an opportunity with the client credentials access token am getting the above error , in case of authorization code access token i can able to create an opportunity.

Error: [
    {
        "errorCode": "NOT_FOUND",
        "message": "The requested resource does not exist"
    }
]

Curl:

curl --location --request POST 'https://xyzsolutions7-dev-ed.develop.my.salesforce.com/services/data/v50.0/sobjects/Opportunity/' \
--header 'Authorization: Bearer 00D5h000008Nj5y!ARkAQDD7JVaKTCHHT.dHTnOIUN680XIfXgzvYr3HqVGz7yu5OZWATT9HqljfV5cHHi355tbTNuOrmomzo3Tm1dUY2S_CGAi.' \
--header 'Content-Type: application/json' \
--header 'Cookie: BrowserId=U-v_xWGkEe64ePPDdIi5iA; CookieConsentPolicy=0:1; LSKey-c$CookieConsentPolicy=0:1' \
--data-raw '{
    "Name": "Sample Opportunity",
    "AccountId": "0015h00001UePQgAAN",
    "StageName": "Prospecting",
    "Amount": 10000,
    "CloseDate": "2023-12-06"
}'

 

While trying to create an opportunity with the client credentials access token am getting the above error , in case of authorization code access token i can able to create an opportunity.

Example for creating Opportunity :
curl https://na1.salesforce.com/services/data/v20.0/sobjects/Opportunity/0AASSFGSEID -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @newrecord.json -X PATCH
Example request body newrecord.json file :
{ "Name":"FFNEw","CloseDate":"2015/02/04","StageName":"Prospecting","Probability":10 }
My ASP.net code :
 
using (WebClient client = new WebClient())
{
client.Headers.Add("Authorization", "Bearer " + token.access_token); client.Headers.Add("Content-Type", "application/json");
var request = (HttpWebRequest)(HttpWebRequest.Create(token.instance_url + "/services/data/v20.0/sobjects/Opportunity/0AASSFGSEID"));
request.Method = "PATCH";
using (var requestWriter = new StreamWriter(request.GetRequestStream()))
{
  requestWriter.Write(json);
  requestWriter.Flush();
  requestWriter.Close();
}
var response = request.GetResponse();
}
Getting Error 400 Bad Request in "request.GetResponse()".