Can I retrieve Salesforce data out of SF using the REST API? - api

I'm having a bad time figuring out if I can retreive an authenticated user's data using the REST API.
I have managed to authenticate using OAuth 2.0, retrieve all the SObjects ( and each object instances description) using the REST API, but can't figure out how can I can I retrieve the actual data for each object instances.
I have read the article on "which API should I use?" but it's just not clear enough.
Does any of this makes sense?

You can use the SOQL Query REST endpoint /services/data/{version}/query?q={soqlQuery}, e.g. with curl
curl -v https://na1.salesforce.com/services/data/v34.0/query?q=SELECT+ID,NAME+FROM+ACCOUNT -H "Authorization: Bearer $SID"
If you've already got the SObject definitions then you can use the object/field info to programmatically build the queries (there's no select *, so you need to include every field you want)

you may want to use
URI something like /vXX.X/sobjects/SObjectName/updated/?start=startDateAndTime&end=endDateAndTime
SObjectName can be Account, Opportunity,OpportunityLineItem

Related

Postman request - how to get data from endpoint based on API documentation

I want to retrieve data from a data warehouse that has a web-based API, I need to use an API key for authentication and use the GET / Customers command to retrieve the list of customers data, but when I am using that same thing in postman, it's returning the same documentation page of the data warehouse?
I am new to this any help will be really appreciated.
The URL doesn't look valid:
You need a base URL, endpoint, http method, authentication scheme, and credential or a token etc.
I don't know details about your system and API, so let's see an example:
base url is https://stackoverflow.com; your current base url is localhost:4444, is your server running on your machine? If so, it might be correct, but I assumer you're talking about a server running somewhere else, not on your computer
endpoint (path parameter) is /questions/69883697, in your case /customers
http method is GET and you find it here in Postman; it also means it will not go into query parameters where you put it:
authentication scheme - your docs mentions an api key that goes into a header called Authorization, so you have to set it in Headers, not as a query parameter:
Read carefully what's on your screen, Postman uses the same language as your API documentation, so if your doc speaks about headers, you need to go into Headers tab in Postman.

How to define API Key in google apis explorer?

I am just testing out the Google Sheets API at:
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
I'm using the Try this API section to fill in the request parameters and execute the request (appending a row to a sheet).
I have followed Step 1 here:
https://developers.google.com/sheets/api/quickstart/js
In order to:
Enable Google Sheets API
Create an API Key
I therefore have:
Client ID
Client Secret
API Key
In the Try this API > Credentials section, there are two checkboxes:
Google OAuth 2.0
API key
I tried to uncheck the Google OAuth 2.0 option so that i could just make the request using the API Key - however I cannot see where I can enter the API Key.
How can I define the API Key in the Try this API section so that I can make a request with only the API Key (and not Google OAuth 2.0 ).
How about this answer?
Issue and workaround:
Unfortunately, in the current stage, "Try this API" cannot be directly used by manually inputting the API key and access token. But in this case, there is a workaround. Please see the below figure.
This is the window of "Try this API". When you see this, you can see the clickable square box at the upper right as shown in the figure. Please click it. By this, you can see the expanded "Try this API" as following figure.
Here, please input the required parameters you want to use. By this, you can see the curl sample as follows.
curl --request POST \
'https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEETID/values/RANGE:append?valueInputOption=USER_ENTERED&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"values":[["sample value"]]}' \
--compressed
By using this command, you can use the API by manually inputting the API key and access token.
But, here, there is an important point. At Google API, the API key cannot be used for the method except for GET method. The API key can use only GET method for the publicly shared contents. Please be careful this. So when you want to use "Method: spreadsheets.values.append" in Sheets API by manually inputting the API key and the access token, please use the access token. Because this method uses the POST method. By this, you can test the API. Also, you can see the required scopes at the official document.
By the way, when you want to use only the API key, you are not required to use --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]'. And also, when you want to use only the access token, you are not required to use &key=[YOUR_API_KEY].
At the expanded "Try this API", you can also see HTTP request and the sample script of Javascript there.
Note:
When you want to request the Sheets API using the API key, please publicly share the Spreadsheet. By this, the value can be retrieved using the GET method like "Method: spreadsheets.values.get", "Method: spreadsheets.get" and so on.
When you want to see the method for retrieving the access token, you can see it at the official documents like here, here.
Reference:
Method: spreadsheets.values.append
I think the correct answer to this question is: It is not possible to use the API Explorer to actually send a request to a Google API if that API requires any sort of API key. The Explorer appears to be for creating requests that you then copy and use in your code. There does not appear to be any way to add the API key (or anything else) directly to the Explorer interface.
This all begs the question of why the Explorer has an "EXECUTE" button if you cannot execute anything (except perhaps API requests that do not require any sort of access credentials).
It is bizarre. I would love to be proven wrong, but I don't think I am.

How to apply cron jobs to Api methods that requires authntication?

Hello frinds presently i am doing manually authentication and getting user tweets and post form various api like instagram,tweeter,youtube but it requires authentication .
Now i want to automate the process and wish to run cron so i can fetch data every hour with authentication.
I know it is possible by passing access token in url methods but no idea how to do it.
first of all you need to have those access tokens. I'll explain the YouTube API and will also write other API's links. Process is similar in almost every API first you get the token then you pass it in URL.
YouTube API :
Here is a document about YouTube API which will help you create your own access key. After creating it just pass the key in URL with key=YOUR_API_KEY. You can retrieve datas from these links they might also give you an idea about how to use the api key : Videos , Channels (There are examples in the documents for JAVA, PHP and Python ). If you are using PHP you can use this curl function for authentication and retrieving datas.

To integrate with Silverpop

Can anyone guide how to integrate with Silverpop, using OAuth(tokens)?
I referred this link
connecting to web api using c#
and I was able to get access token. After this I don't know how to proceed.
Thanks.
Take a look at my github repo:
https://github.com/marcelluseasley/IBM-Marketing-Cloud-XML-API-Wrapper
It isn't finished, but I started working on an XML API wrapper for the Silverpop API. First of all, if you are trying to integrate with the API, you should be able to contact client support and get a copy of the API PDF.
In any case, you should have a client id, client secret, and refresh token. You will need these three things along with a header value of "refresh_token" for the "grant_type" header key.
So you will first sent a post to https://api(pod number).silverpop.com/oauth/token . This will return an access token in a json dictionary ("access_token").
Any subsequent calls made to the API endpoint (https://api(pod number).silverpop.com/XMLAPI will require that you pass this access token in the header section of your request:
"Authorization:" would be the header key and
"Bearer: (access token)" would be the header value
Looking at my code will make it clearer if you are using Python. Your best bet is to get a copy of the API documentation. You have to be a Silverpop client to get a copy though.
Good luck.
Check the follwing:
http://www.codeproject.com/Articles/758362/SilverPop-Integration
Follow the step by step guide.

How to make twitter api calls using access token

I have managed to get an access token from the twitter api. Now I want to use that token for my further data fetching things, so please help me here to get the details of my twitter account.
For example, lets say I wanted to get the user's data, so when I tested this in apigee console, I got my result.
But how to get the same result, using same api, by hitting on a browser using the access token
something like this
Please help
It's a little more complex than the URL you suggested, but you can use Twitter's OAuth tool to generate the OAuth signature you need to make requests to its Home Timeline API call.
You can find the OAuth tool here:
https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline#oauth-tool
it's not like that when making twitter api calls you need to send consumer key, consumer secret, your_access_token and your_access_token_secret together
Eg: oauth_consumer_key="KEY",oauth_signature_method="HMAC-SHA1",oauth_timestamp="TIMESTAMP",oauth_nonce="NONCE",oauth_version="1.0",oauth_token="YOUR_TOKEN",oauth_signature="SIGN"
Source: https://twittercommunity.com/t/getting-the-user-details-using-access-token/6325/3