Search code examples
salesforceapexsalesforce-lightning

How to create CURL command for POST method for Salesforce Account Object using Salesforce Tooling API On Postman?


Hi i am able to get OAUTH token using below article,but i need to send POST method for Accounts using Salesforce Tooling API On Postman

i am using v45.0 version of salesforce,can some one tell me what should be below things:-

1)Rest end point for standard account object which needs to be hit using Postman 2)Body json payload which needs to be sent along with Rest endpoint Postman

I tried sending mandatory fields of Account object but got 404 status code that is Bad Request, Please help me in building a rest end point curl command for standard salesforce Account object

https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_rest_resource_examples.htm

Thanks In advance, Carolyn


Solution

  • If you have basics sorted (you can log in and query successfully from Postman) it's bit easier to explore the APIs using Workbench -> Utilities -> Rest Explorer https://workbench.developerforce.com/restExplorer.php

    Or - bit more work but will pay off once you set it up - you can download a collection of Postman API calls for many things you could need: https://github.com/forcedotcom/postman-salesforce-apis

    Anyway. Ditch the tooling api, use normal rest api.

    To insert single account

    send POST

    to {base url you got from login result}/services/data/v49.0/sobjects/Account with body similar to

    {
        "Name" : "Foobar Inc.",
        "Website" : "http://example.com",
        "NumberOfEmployees" : 123
    }
    

    (you might need your own required fields but generally it should work)

    Response will be something like

    {
      "id" : "0014u00001ojYsQAAU",
      "success" : true,
      "errors" : [ ]
    }
    

    You can also send up to 200 records in 1 message, create account and related contacts in one go (useful because it saves you some headache mapping ids - and if one of contact fails to load you may want to undo the whole operation, not be left with orphan/widow records). Check https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_flat.htm out and other links from same chapter