0

I am very new to integration part.

I need to do one requirement. I have one Custom Object in which I am storing data. Now I want to expose this data to the external system. For this, as I know I need to create the API and expose it to the external system. but I am totally clueless about this.

I have done it through Postman, I am able to get the access token and fetch the data, but how can I convert it to the code. Please help!

Can you guys please send me the steps that can follow to achieve this scenario.

Thanks in advance Nirav

3
  • This is very broad question so be more specific. what do you mean by convert the code? what is your external system type/language.
    – Himanshu
    Dec 7, 2017 at 7:06
  • The requirement is I need to give the API which can fetch data, and for generating URL I need to put some logic like if date is null the add some info based on date field and so on
    – Nirav Shah
    Dec 7, 2017 at 7:31
  • External system is the website which is handled by some other one
    – Nirav Shah
    Dec 7, 2017 at 7:38

2 Answers 2

2

There are two solutions of your requirement

  1. OOB Rest API:

    Use the Query resource to execute a SOQL query that returns all the results in a single response, or if needed, returns part of the results and an identifier used to retrieve the remaining results.

    In this solution External system (java,.net,php) application will consume Saleforce API like any other standard rest api.

    Here are the steps for that:

    • Generate token using auth password flow by hitting https://test.salesforce.com/services/oauth2/token
    • Read token,instance url from step 1 and call Salesforce service endpoint https://yourInstance url/services/data/v20.0/query/? q=SELECT+name,id+from+Account"
  2. Develop custom rest api

    By utilizing custom Apex REST endpoints, developers can tailor the REST API to suit the business needs of their application.

    An endpoint can be defined with an Apex Class using the @RestResource annotation, and the method annotations allow the endpoint to behave specifically for creating, updating, deleting and querying data within the instance.

    In areas where the REST API has already proven successful, i.e. third party web integrations and mobile applications – the ability to use Apex REST will make those applications even more versatile and powerful.

    So in this solution you will create your own rest api and you will expose to external system.

I would recommend solution 1 as there is no custom development required and you can perform all the calculation in your external system (.net/php/java) application for example if date is null perform some step etc.

1
  • Thanks, @Himanshu... I have to develop the custom rest API as I need to provide the formatted data. Again thanks for your help
    – Nirav Shah
    Dec 7, 2017 at 12:59
0

In your question ,you informed that you tried in Postman and able to fetch record from salesforce. Postman has a option to convert your request to respective code. enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .