Got error on invoking the IBM Softlayer "getCpuMetricImage" rest API - rest

I have an active IBM Softlayer account. I am getting the error as
{"error":"One of types passed is not in the proper container.",
"code":"SoftLayer_Exception_Metric_Tracking_Object_InvalidDataType"}
when trying to fetch the cpu metric image using the below rest API with valid Virtual_Guest_Id and Snapshot_Range":
"api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/<Virtual_Guest_Id>/getCpuMetricImage/<Snapshot_Range>"
But I am getting the proper response while fetching the memory metric image using the similar rest API listed below:
"api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/<Virtual_Guest_Id>/getMemoryMetricImage/<Snapshot_Range>"

First of all your REST request is wrong it should something like this:
POST https://$USERNAME:$APIKEY#api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/$VSIID/getCpuMetricImage
PAYLOAD:
{
"parameters": ["day","9/2/2017"]
}
Second the method is not working currently I am going to report it, but I do not have idea when they are going to fix it.
Another thing to point out is that the Softlayer's control portal do not use that method to display the graph, so is likely that the image returned by the method and the graph in the portal are going to be different. If you want the same inforamtion I recomend you to use the same method see this forum for more information:
SoftLayer API CPU usage mismatch
The method in the forum above will return you the data of the graph and then you are going to need to represent that information in a graph using your own code.
Regards

Related

Facebook Insights API not returning store visits data

I am trying to retrieve Store Visits data from the Facebook Insights API. Based on their documentation, these should be available by specifying the following parameters:
store_visit_actions
cost_per_store_visit_actions
When I use store_visit_actions as a parameter, no data is returned. I know data exists because it is displayed through their UI reporting tool.
When I use cost_per_store_visit_actions, I receive a 100 invalid param error:
cost_per_store_visit_actions is not valid for fields param.
These params are listed as "In Development", however, I'm retrieving other development parameters without issue. Is anyone facing the same issue or know how to fix?
this is because the metrics
store_visit_actions
cost_per_store_visit_actions
are deprecated in facebook api v11.0. You can checkout this link:
https://developers.facebook.com/docs/graph-api/changelog/version11.0/

Querying "Pepper Public API" with requests

I'm trying to query the HotUKDeals API. The page says
This API follow some of the REST idioms.
It is available under the https://{hostname}/rest_api/v2 root URI.
At the top of the page, it says
https://www.pepper.com/rest_api/v2
So I have tried writing
import requests
r = requests.get('https://www.pepper.com/rest_api/v2')
r.status_code
as per the requests documentation. However, this returns 404.
Does this mean that the HotUKDeals API isn't working, or am I making a mistake in querying it?
Disclaimer: I've been using Python for couple of years but am a requests noob.
the problem is that this Api does only gives you 200s to actual querys. (You need to add something behind v2 as mentioned in the docs)

issues getting events data using facebook graph api v2.5

Hello i'm trying to get some event information using the facebook graph api v2.5 but I keep getting the error message facebook.GraphAPIError: Unknown path components: /144259682284406. It works without the fields when I don't specify v2.5 however I need to use v2.5 to get the necessary fields
/v2.5/144259682284406?fields=events{name,id,timezone,start_time,end_time,picture,description,category,type,attending_count,interested_count,declined_count}
Blockquote
The exact same request worked in Graph API Explorer or when calling the API via URL directly – so it must have been something in how you pass the parameter in your SDK code.
Checking http://facebook-sdk.readthedocs.org/en/latest/api.html it turns out, that the API version has to be passed when the facebook.GraphAPI object instance is created,
graph = facebook.GraphAPI(access_token='your_token', version='2.2')
That way the SDK will take care of putting that version string into the URLs that the API requests are made to by itself, so that you don’t have to take care of that any more in the following code where you make the API calls.
Try this ;)
The id 144259682284406 you are using is a page object and if you want to get page events you should query like this:
page/events/?fields=field1,field2,... in your case:
/v2.5/144259682284406/events/?fields=name,id,timezone,start_time,end_time,picture,description,category,type,attending_count,interested_count,declined_count

Creating saved target group in facebook audience

I need to create Saved Target Group in facebook programmatically like PowerEditor does it here https://www.facebook.com/ads/manage/powereditor.
During inspecting the browser's console when saving through the Power Editor I've discovered that such kind of an endpoint is used:
"https://graph.facebook.com/v2.2/act_#AD_ACCOUNT_ID#/audiences", but the method called is encrypted and there is no information about this kind of endpoint in the facebook API documentation.
Seems like Power Editor uses more extended API or not all the API is well documented.
Did anybody experience something similar?
Thanks
Not all of the functionality available in Power Editor is available in the public API or vice versa -
If what you're asking about is not in the public API documentation, it's not part of the API that is available publicly -
It would be dangerous to assume that an undocumented endpoint will continue to work or that it works in a specific way based on observing another app (Power Editor) calling it
You can use saved_audiences API.
Here is Graph Explorer request examples:
POST:
https://developers.facebook.com/tools/explorer/765026780221012?method=POST&path=act_&Fsaved_audiences&version=v2.5&name=foo&targeting={ "age_min":18, "age_max":65, "page_types":[ "desktop-and-mobile-and-external" ], "geo_locations":{ "countries":[ "US" ], "location_types":[ "home" ] } }
GET ALL:
https://developers.facebook.com/tools/explorer/765026780221012?method=GET&path=act_%2Fsaved_audiences&version=v2.5

List of Facebook error codes

I'm looking for a list of all Facebook can return when you try to fetch infos using Graph API. Can anyone help?
Facebook returns a 400 HTTP error, and a JSON content like:
{
"error": {
"type": "OAuthException",
"message": "Invalid OAuth access token signature."
}
}
I'm searching the different returns of the same kind it is possible to get.
Facebook used to have this published somewhere, but for whatever reason it was removed. But you can find the full list here:
http://www.takwing.idv.hk/tech/fb_dev/faq/general/gen_10.html
There seems to be a list now for the errors.
I posted answer for the same question here: Facebook Graph API error code list
(I found the list here https://developers.facebook.com/docs/graph-api/using-graph-api/error-handling)
In case Takwing's copy ever comes down, here's another copy: http://fbdevwiki.com/wiki/Error_codes
These codes were primarily for the REST API, but they do also come up with the Graph API. Some of the Graph API calls have underlying FQL calls that return the FQL error codes. And the direct FQL queries are still part of the currently accepted API.
Update: I'm trying to keep this list up-to-date. Please feel free to make changes as you encounter new errors.
I am trying to keep an updated list of error codes based on previous outdated information.
You can find the repo here http://github.com/phwd/fbec and it has been updated with Test User and Credit Error codes from the Facebook Documentation.
Currently looking for the constant name for "Error Code 2500" and some error descriptions may have changed. I hope to keep on top of this.
There is an official error code page, now:
https://developers.facebook.com/docs/marketing-api/error-reference/
It still doesn't look comprehensive...