Getting a list of all Media in Instagram with Graph API - instagram-graph-api

In my code, I have been pulling the list of media in Instagram using the following URL:
https://graph.facebook.com/{app_id}/media?fields=media_url,{..some fields here...}&limit=10000&access_token={my_access_token}
This was working fine and I didn't touch the code for a month. Now suddenly it gives the error:
{
"error": {
"message": "(#100) Tried accessing nonexisting field (media) on node type (Application)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "Aty4vnPpLWfGq9Hj6hQFtZR"
}
}
Nothing in the documentation says that media is no longer available. Graph API version has updated from v14 to v15 since I used it, but the request isn't working on either version.
Access token is fine because other requests are working correctly.
Does anyone have any insights? What alternatives do I have?

I think you are defining an invalid field. Below is a list of fields you can use. Also i suggest you also try instagram account id instead of app_id.
fields=[id,ig_id,media_product_type,media_type,media_url,thumbnail_url,timestamp,
username,like_count,comments_count]
final url:
https://graph.facebook.com/v14.0/{instagram_account_id}/media?fields=id,ig_id,media_product_type,media_type,media_url,thumbnail_url,timestamp,
username,like_count,comments_count&access_token={my_access_token}

Related

YouTube Data API V3 unkownPart "localizations"

I have been trying to fetch all videos from a playlist using YouTube Data API, which worked like a char; next, I wanted to try and filter videos based on languages, so I wanted to try to include the "localizations" part. However, whenever I do, I get a 400 response stating that "localizations" is "unkownPart". From what I could see in the documentation, I should have my GET request structured properly:
`https://youtube.googleapis.com/youtube/v3/playlistItems?part=localizations&part=snippet&maxResults=${limit}&playlistId=${playlistId}&key=${apiKey}`
Error message in postman:
{
"error": {
"code": 400,
"message": "'localizations'",
"errors": [
{
"message": "'localizations'",
"domain": "youtube.part",
"reason": "unknownPart",
"location": "part",
"locationType": "parameter"
}
]
}
}
"localizations" is a direct copy from the documentation. The GET request works fine if I remove it so I'm confident that the problem is either the order or my parameters, or the combinations of parameters in use (though I couldn't find anything about incompatible parameters in the documentation).
Parameters order goes as follows:
localizations
snippet
playlistId
key
EDIT: link to the documentation: https://developers.google.com/youtube/v3/docs/playlists/list
After sending the Issue Report it was discovered that I had been using the wrong API endpoint. Somehow (I can't remember why) I was using the "playlistItem" endpoint which doesn't support "localizations", and needed to shift to using the "playlists" endpoint instead.
Furthermore when using a combination of both "snippet" and "localization", they should be within the same parameter but comma-separated, however, Postman doesn't auto-convert the commas in the parameters to "%2C" and therefore would cause further trouble understanding the requests. Fixing these 2 steps, it now works as intended.

preferredDataLocation field in microsoft graph API not working in v1.0

I am working on a feature where I need to find preferredDataLocation field for all the users but it turns out that it is currently in beta version. How can we check estimated date of this feature going into stable version? I tried to check on Microsoft 365 Roadmap but couldn't find it. I tried to use following request
https://graph.microsoft.com/v1.0/users/delta$select=id,preferredDataLocation
but it gives the following error
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Invalid property: preferredDataLocation",
"innerError": {
"request-id": "c93a43cb-fa9d-4803-801a-5864439ad66d",
"date": "2020-06-02T09:24:30"
}
}
}
If I use request without delta then it works fine. Example
https://graph.microsoft.com/v1.0/users$select=id,preferredDataLocation
After checking in the metadata the property is not available in v1.0 for users today (only groups). Hence why it fails when requested for delta query. I created a documentation issue to get the documentation fixed.
You can perform the same query using the beta endpoint today as a workaround.

Making a simple authorized request to eBay

I'm planning to integrate a website with eBay using PHP, but first I'm using Postman to test everything.
Authorization took me an entire day, but I think I've got it working now. (I had to update to the latest version of Postman, then I got it to create a token for me.)
I say I think because I haven't managed to get a single request to work. I deliberately chose bulkGetInventoryItem (documentation) as it seemed like one of the easier authorized requests to get working. I just know that when the authentication settings are wrong, I get a different error message to when they are right.
For troubleshooting reasons, I made a token with all the scopes:
https://api.ebay.com/oauth/api_scope
https://api.ebay.com/oauth/api_scope/sell.marketing
https://api.ebay.com/oauth/api_scope/sell.inventory
https://api.ebay.com/oauth/api_scope/sell.account
https://api.ebay.com/oauth/api_scope/sell.fulfillment
https://api.ebay.com/oauth/api_scope/sell.finances
https://api.ebay.com/oauth/api_scope/sell.payment.dispute
https://api.ebay.com/oauth/api_scope/commerce.identity.readonly
(added as space-separated list of links)
I have changed one of the eBay listings to have an SKU of "123456" just for this test, however the error I get is exactly the same as if I change "sku": "123456" to "sku": "anObviouslyFakeSKU", but anything else I change creates a new error, so I'm suspecting the issue to be SKU related, but maybe it isn't. (I've found the eBay API to be very poor at sending relevant error messages.)
I'm quite new to Postman, so it's likely a rookie mistake.
Earlier errors have shown to be minor punctuation issues or wrong radio buttons ticked, so hopefully whatever the error is this time, it should appear in this screenshot.
What did I do wrong this time? (Let me know if there are any other screenshots I can send that might help.)
To help, both with the post's SEO, and ease of copy/pasting, I am transcribing the important text in the screenshot above:
url
POST https://api.ebay.com/sell/inventory/v1/bulk_get_inventory_item
body, raw
{
"requests": [
{
"sku": "123456"
}
]
}
output
{
"errors": [
{
"errorId": 2003,
"domain": "ACCESS",
"category": "APPLICATION",
"message": "Internal error",
"longMessage": "There was a problem with an eBay internal system or process. Contact eBay developer support for assistance",
"parameters": [
{
"name": "reason",
"value": "Failed to transform underlying error response, see logs."
}
]
}
]
}
Update:
One more screenshot
Update 2:
Another screenshot
A few things you need to check for in Postman.
When you authenticate and receive a token are you posting that token with your api calls like this one POST https://api.ebay.com/sell/inventory/v1/bulk_get_inventory_item?
Have you set the Authorization HTTP header for authentication authorization?
Have you set the Content-Type header for the call to application/json?
More info here: https://developer.ebay.com/api-docs/sell/inventory/resources/inventory_item/methods/bulkGetInventoryItem
Update
Authorization with environment variable in Postman:
Postman environment variables documentation:
https://learning.postman.com/docs/postman/variables-and-environments/variables/
I figured out the issue. My biggest mistake was choosing bulkGetInventoryItem as the "simplest" call. I should have chosen getInventoryItem, as the error reporting on that function is far more user friendly.
So the error I got, for exactly the same request was "We didn't find the entity you are requesting. Please verify the request"
A quick google of the error found me this page https://forums.developer.ebay.com/questions/17883/cannot-get-my-listed-product-by-get-inventory-api.html which led me to the correct answer!
The inventory item I was trying to access was unreachable because it was not created through the developer API.
I hope this answer helps others, as it wasted a full day of my life trying getInventoryItem before tackling bulkGetInventoryItem.

Microsoft Graph API - SendMail http 400 - API url from documentation not working

My application sends email using Microsoft Graph. We followed the documentation, this was working as expected for almost a year:
https://graph.microsoft.com/v1.0/users/me/microsoft.graph.sendmail
Since 3/8/2019, the same code sendmail API in PROD started failing with the HTTP 400 - Bad Request:
{
"error": {
"code": "TargetIdShouldNotBeMeOrWhitespace",
"message": "Id is malformed.",
"innerError": {
"request-id": "0de5a4eb-dac4-4d98-a4b4-178e503a6657",
"date": "2019-03-19T17:16:20"
}
}
}
As a part of the investigation, we found that the SendMail documentation has a different URL used in the examples than the API help section. We were successful when calling this URL:
https://graph.microsoft.com/v1.0/me/sendmail
Questions:
Clearly looks like there was some update on the Graph API happened around 3/8/2019 that disabled working of the earlier URL
Documentation has 2 URL's that are misleading/confusing: one is the API help section and one in examples. As of now the API URL in the help section is no longer working. That should be fixed with the correct URL to be used.
Why was such breaking change like this introduced that caused a PROD outage for our application?
What is the official channel to get these changes?
The correct URI is https://graph.microsoft.com/v1.0/me/microsoft.graph.sendmail (not /me)
The correct API route is: https://graph.microsoft.com/v1.0/me/sendMail
You can find more practical samples here: https://developer.microsoft.com/en-us/graph/graph-explorer#

Simplest way to display upcoming events from a public Google calendar?

I have a public calendar on the site. I need to display upcoming events on the front page.
After spending the whole day on this I am about to give up. Google is disabling older API there is no documentation or anything. I am parsing the RSS feed:
http://www.google.com/calendar/feeds/.../public/basic?futureevents=true
And grabbing feed/entry/update and feed/entry/title from XML. I read somewhere that futureevents will display upcoming events. However I get the list of older events.
Okay, then I tried to use API V3 https://developers.google.com/google-apps/calendar/v3/reference/events/list
Here is the responce I get:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
I jumped through more hoops and installed their ruby code sample as I need this for Rails site.
It sort of worked but it requires user to confirm access to their own calendar. I don't need that. Plus it seems that authentication only valid for a day.
The said calendar is public. It is being displayed in iframe on the site with xml and ical feed. All I need is to parse upcoming events to show them on front page.
What is the way to do it without authorization and other ridiculous stuff?
//This works for me! js:
var request = gapi.client.calendar.events.list({
'calendarId': 'xxx',
'timeMin': (new Date()).toISOString(),
'showDeleted': false,
'singleEvents': true,
'maxResults': 1,
'orderBy': 'startTime'
});
request.execute(function(resp) {}
Use this wizard to create a new API project: https://console.developers.google.com/start/api?id=calendar Then click on "create new key" (choose server key). Then do a request to https://www.googleapis.com/calendar/v3/calendars//events?key={YOUR_API_KEY} replacing the email and api key with your values.

Resources