Podio filter results missing external_id - podio

Items returned by filter have their external_id set to null for one of our apps. For example, running this:
curl -X POST -H 'Content-Type: application/json' -H 'Authorization: OAuth2 [Token]' -d '{"limit":1}' 'https://api.podio.com/item/app/[App ID]/filter?fields=items.view(micro).fields(external_id)'
Returns all the requested data for one app:
{"filtered":119,"total":119,"items":[{"sharefile_vault_url":null,"title":"Title...","app_item_id":119,"link":"https:\/\/podio.com\/...","item_id":1234,"sharefile_vault_folder_id":null,"app_item_id_formatted":"VJD119","external_id":"share_1234","revision":0}]}
The same request returns this for another app:
{"filtered":138,"total":138,"items":[{"sharefile_vault_url":null,"title":"Title...","app_item_id":149,"link":"https:\/\/podio.com\/...","item_id":5678,"sharefile_vault_folder_id":null,"external_id":null,"revision":16}]}
Do I need to configure anything in Podio to get it to provide an external_id for the items? The first app is just a copy of the second one so it shouldn't be configured differently.
I've redacted some of the returned data, let me know if any of that is needed to help debug. We're actually using the PHP library for this, but since directly calling the API as above has the same issue I don't think that's relevant.

Most likely items from your second app have no external_id, and that's why Podio API returns null.

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.

wit.ai capture free text from whatever the user gives you

I have the following problems.
I have several points into the conversation where I have to capture "free" text.
Ex: what are your thoughts on xyz ? why do you want xyz ?... They are opened questions and the user can answer whatever they want.
How to I enable this ? because I tried different combinations and the bot either repeats some questions or skips some ?
Thank you
If you're using the converse api you can try to set a corresponding context property before you send the response back to wit.ai and then use the updated context in your story.
For instance, I created a test story for you (the app is empty - just created the whole thing from scratch):
As the result I was able to get into this point during the conversation:
So what you need to do is to define an action like captureUserInput in my example and instruct your bot to await for a certain key in your context. In my example it's represented by the user_input key.
In your client app, you need to react to a corresponding action (captureUserInput in my example) appropriately.
When sending the POST to wit.ai converse API set the corresponding key. For instance:
$ curl -XPOST 'https://api.wit.ai/converse?v=20160526&session_id=some_session_id' \
-d '{"user_input":"put what the user responded here"}' \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H 'Authorization: Bearer $TOKEN'
The wit.ai engine should capture your context and take it into account when responding back to you (like This is what you said: {user_input} in my example)
I hope this will work for you. I based my findings on the following:
https://wit.ai/docs/quickstart - see the step 4
and the wit.ai reference for the converse api.
I got the same problem and ended up solving it client-side by setting a certain context. I have an older bot that doesn't have the "Stories" interface, so this solution may not apply to your case, but maybe it is of some help.
When the bot sends an open question, it should also set a special context i.e. open_question_xyz or something like that, and send it back to the client app.
When the client app receives the context, save it to some var.
Before processing the next user input, your app first checks if the open_context_xyz var is set, and if it is, instead of sending the query directly to wit.ai, it captures the raw text, and also sets a context like resolved_open_question_xyz so the bot knows where to pick up the conversation.

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 get fields in page layout

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"