How to get fields in page layout - api

Using the REST API in Salesforce, I want to get a list of the fields in a page layout.
Does anyone have any idea how I do this?

As of API version 28.0 (Summer '13), you can get the page layouts using /sobjects/<object>/describe/layouts/<recordtypeid>, e.g.
/services/data/v28.0/sobjects/Account/describe/layouts/012A00000004vpXIAQ

You can't do this from the REST API, you can get it from the describeLayout call in the SOAP API.

I'm not sure if the REST API can accomplish this, however you could use the Salesforce metadata API to do it.

You can do with rest api by calling object request.
curl https://***yourInstance***.salesforce.com/services/data/v35.0/sobjects/Global/describe/layouts/ -H "Authorization: Bearer token"

Related

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.

Where to use the API authorisation key in this API?

I am working with the following api:
https://www.football-data.org/documentation/api
I have gotten myself an api key and I tried to make the example request:
https://api.football-data.org/v2/teams/86/matches?status=SCHEDULED
of course I get the error
{"message":"The resource you are looking for is restricted. Please pass a valid API token and check your subscription for permission.","errorCode":403}
So the question is, is how do I give the website my api key to allow me to make these requests?
Looking at the python snippet they create a dictionary with the the api key as a value and pass that to the request. How can I make this in my browser?
I tried
https://api.football-data.org/v2/teams/86/matches?status=SCHEDULED&%22X-Auth-Token%22=%22MYAPIKEY%22
and it did not work.
You are passing your API key as a query parameter, which is not in line with the API specification.
The API needs the key as an HTTP header. You cannot easily do that in a web browser. I'd suggest getting something like Postman or to do it on the command-line:
curl -i -H "X-Auth-Token: MYAPIKEY" "https://api.football-data.org/v2/teams/86/matches?status=SCHEDULED"
You might have figured it out by now, but I am dropping this for anyone else looking on how to do it in Python:
import requests
from pprint import pprint
token = "" # Write the api key emailed to you here
headers = {
'X-Auth-Token': token,
}
r = requests.get('http://api.football-data.org/v2/competitions/EC/teams', headers=headers).json()
pprint(r, indent=2, depth=1, compact=True)
If you're using postman like #Jakob Löhnertz suggested.
You want to first enter the api
Then go over to the Headers tab, put in "X-Auth-Token" as your Key and your unique API token as your value. Hit send and you should be all good.
Finally, be sure to go through here to see the list of available competitions for a free account.

Update issue fields in JIRA

Hi I am using postman client for Chrome to run my rest api calls. I am trying to update issue in JIRA via rest API. I have referred to JIRA API also for updating an issue.
I am using PUT method to update an issue fields. Here is the syntax.
PUT /rest/api/2/issue/{issueIdOrKey}
I am trying to update summary field like this.
{"update":{"summary":[{"set":"Bug in business logic"}]}}
But it is giving me the 400 bad request error.
and in the body its showing message "No content to map to Object due to end of input".
Please find the attached screenshot for more reference. Thanks in Advance.Jira Update issue
In postman rest API client, add the json object to Body as in the below picture.
I added authorization as Basic Authorization and provided JIRA credentials.
Note that the body should be raw and type should be JSON(application/json) instead of Text(default).
Response for this PUT request is 204 when update is successful.
Here is REST API Documentation for additional options.

Can I retrieve Salesforce data out of SF using the REST 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

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