GET request to Patch Management API (Patch Manager Plus - Cloud) - axios

I followed the instructions in the Patch Manager Plus - Cloud (https://www.manageengine.com/patch-management/api/) . And then get information (like refresh_token, client_id, client_secret), get access_token for every hour.
When trying to initiate a GET request to api/1.3/som/computers, I get the following response back.
{
"message_response": "Unable to retrieve details, Please try again later.",
"error_code": 90004,
"error": "invalid input found",
"message_version": "1.0",
"status": "error"
}
My code is as follows:
axios.get('https://patch.manageengine.com/api/1.3/som/computers', {
headers: {
"Authorization": << access_token >>
}
})
I think there is a problem with the header such as missing some parameters. (I tried running the api in the browser (logged in) and got the data). I also searched but couldn't find a description for this part.
Can anybody help me, please?

Related

Facebook Marketing API returns error on "breakdowns call"

I'm trying to make an API call with the folowing URL
act_XXXXXXXX/insights?fields=ad_id,clicks,unique_clicks,impressions,reach,spend,date_start,date_stop,actions,action_values,unique_actions,account_id&level=ad&breakdowns=platform_position&time_range={"since":"2019-09-07","until":"2019-09-07"}
and the response is :
{
"error": {
"message": "(#100) Current combination of data breakdown columns (action_type, platform_position) is invalid ",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "XXXXXXXXXXXXXXXXXXXX"
}
}
the reason is in "breakdown" value = "platform_position"
but the problem is that I need exactly that breakdown :(
when I do an API call and change "breakdown" in URL to something else, for example to "publisher_platform":
act_XXXXXXX/insights?fields=ad_id,clicks,unique_clicks,impressions,reach,spend,date_start,date_stop,actions,action_values,unique_actions,account_id&level=ad&breakdowns=publisher_platform&time_range={"since":"2019-09-07","until":"2019-09-07"}
it is OK and responds with data.
I don't know why it happens because I'm not specifying any "action_type" breakdown but it tells that I am :(
What I've tried:
I tried to remove all the parameters from that URL one by one but it still returns an error
The main questions are: why the API call for "breakdown" value = "platform_position" fails and how to make it work.
Thanks.
PS: you can use FB API testing tool to test requests to FB api.
I'm using API version v8.0
You will need both publisher and position:
breakdowns=publisher_platform,platform_position

How to make a call to Firestore using gRPC

I'm trying to build a gRPC client for Google's Firestore API in Elixir.
Before starting to write some code , I thought that it would be wise to first start with BloomRPC in order to debug the issue.
As base url, I'm using https://firestore.googleapis.com where I pinned the rot certificate.
As auth I'm using an access_token obtained using oauth with the following 2 scopes: "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/datastore"
being passed as a Authorization header:
{
"Authorization": "Bearer 29ya.a0AfH6SMBDYZPsVgQv0PMqyGRXypc3DfWF_2jbvAJKMquTaryCvxEB7X1Rbprfk1Ebrwid2bXbcR3Aw-d1Tytlo_lThkyqRDRIbnSz5-nQ3xWklkmjyFMAuQtFCoz01hk3vbgBwd2gdbFNNWiOU_8NqPC_vElyz2-cQ34"
}
And I get back:
{
"error": "3 INVALID_ARGUMENT: Missing required project ID."
}
So clearly I should be passing the project ID somehow but I can't find it anywhere in the docs. Anybody any clues?
I just figured out what I was doing wrong.
Basically the Bearer token I was using is correct (obtained via the OAuth Playground).
The trick was to specify the PROJECT_ID in the parent parameter of the request:
{
"parent": "projects/[project-id]/databases/(default)/documents",
"page_size": 10
}
I should have just read the docs properly :)

Request Sync always returns 404 : "Error: Requested entity was not found."

I'm having a hard time implementing requestSync. It always returns
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
I use Node.js/Express for the backend. The linking/unlinking with the Google Home app work and my actions work as well. It's really the requestSync part that fails.
The closest ticket I've found, though not exactly the same, is this one.
Things I've tried
agentUserId is a string, but if I pass it a number it returns a 400 with the message "Invalid value at 'agent_user_id'".
tried sending agent_user_id instead of agentUserId, this returns a 404 the same error as when I send a agentUserId
tried removing the "async:true" part of the body. did not notice a difference.
during SYNC, hardcoded the value of the agentUserId to eliminate possibility that I'm sending the wrong one. I use that same agentUserId during requestSync and this fails.
tried linking/unlinking multiple times in the google home app
another interesting thing to note : when opening up the "Test Suite" from the actions on google console, I put in that same agentUserId + service account key, and it registers it well : I'm able to see my devices listed correctly. Which leads me to believe that my agentUserId is correct (this may be a false assumption)
I'm 100% sure HomeGraph is enabled as I can see data on the charts in the "Overview" section of the HomeGraph API part of the console.
This is what the curl looks like (same as from the example)
curl -i -s -X POST -H "Content-Type: application/json" -d "{agent_us
er_id: \"1\"}" "https://homegraph.googleapis.com/v1/devices:requestSyn
c?key=API_KEY"
(my agentUserId is 1 in this case)
And this is what it looks like in code :
const res = await fetch(
`https://homegraph.googleapis.com/v1/devices:requestSync?key=${config.googleApiKey}`,
{
method: 'POST',
body: JSON.stringify({
agentUserId: String(userId),
async: true,
}),
headers: { 'Content-Type': 'application/json' },
},
);
Regardless of what I do, the result is always :
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
I don't know where else to look to identify this problem. Any pointers would help. Thank you
Finally found the answer.
It wasn't too far from the one I had posted above. Although my problem is that when I generated an API key, the google home cloud console opened the wrong project by default. I had the wrong API key all along.

Forbidden !! while trying to access the hereapi traces service

I've been working on here API from past one week, I've tested the geofencing and other rest services. I am trying to work on tracking, Where we have to generate a token by giving all the valid credentials. At last, I've got the token as well but when am trying to access the traces one for which the endpoint URL is
https://tracking.api.here.com/traces/v2/{trackingid}
here I've given the trackingid(deviceid) which I've used to generate an access token and included this token as a bearer in authorization I am using postman to test these, my token is valid for only 23 hours
Authorization Bearer {mytoken}
As mentioned I've also provided this x-request-id, I've no idea regarding this x-request-id but came to know about this from this thread and tried to generate uuid and use it for x-request-id
x-request-id 5506b7d0-2fe6-4967-8ad8-cf0f08fdedbf
And I am receiving the response as
{
"code": 403,
"id": "5506b7d0-2fe6-4967-8ad8-cf0f08fdedbf",
"message": "Forbidden",
"error": "Forbidden\n\nThe account does not have the correct
privileges\n"
}
The similar case even when I am trying to access the allotted geofences for that device and how many devices are in that particular geofence. I've read about whitelisting but whatever the service I am requesting for is not on their list. My account was a 90days free trial account
I am new to this hereapi Kindly correct me if I am doing anything wrong.
Kindly Help me out with this issue
Thanks in advance
--Meghana Goud
I've figured it out, I'll include the details here follow the step by step process as mentioned in the documentation
refer this HERE Tracking | API Reference
And follow the step by step process as mentioned in this documentation
The first one, you'll get your bearer token from this endpoint URL https://tracking.api.here.com/users/v2/login which is post
method and set its Content-Type to application/json and provide the username and password in JSON format and send a POST request to it
EndpointURL :https://tracking.api.here.com/users/v2/login
Headers :{"Content-Type":"application/json"}
Input :{"email":"XXXXXX", "password":"XXXX"}
Expected Response:{
"userId": "XXXXXX",
"accessToken": "XXXXX",
"tokenType": "bearer",
"expiresIn": 86399,
"refreshToken": "XXX"
}
the token is valid for only 24 hours. Now use this token for all the rest services you want to access from here-API
Now I would like to get the traces of my device using this endpointURL https://tracking.api.here.com/traces/v2/{trackingid}?count=1 , send a get request to this endpointURL by giving your trackingID, I repeat TrackingID is different from your deviceId TrackingId will be HERE-XXX(UUIDv4) whereas deviceId will be XXXX(UUIDv4)
now set the authorization to Bearer Token and pass an x-request-id which is a UUIDv4
Your request should look like
EndpointURL :https://tracking.api.here.com/traces/v2/{trackingid}?count=1
Headers :{"Authorization":"Bearer XXXXXX","x-request-id":"XXXX(UUIDv4)"}
Expected Response:{
"count": 1,
"data": [
{
"position": {
"lat": 17.44936354,
"lng": 78.36296417,
"accuracy": 45,
"alt": 539
},
"timestamp": 1531462419813,
"payload": {
"refAppData":
{
"batteryState": {
"charging": false,
"level": 52,
"temperature": 25
}
}
}
}
],
"pageToken": "1531462359711"
}
In order to update any data from your device, you'll require your device token which is generated from this endpoint URLhttps://tracking.api.here.com/v2/token you'll get your access token by OAuth1.o Authorization give the respected values as mentioned in the documentation. you'll get the response as
{
"accessToken": "XXXXXX",
"expiresIn": 86399
}
Similarly, you can test other services,
Hope this helps
Meghana

"message": "Unsupported post request. Object with ID does not exist, cannot be loaded due to missing permissions

I have two apps on facebook. In one, I can make API calls. In the other, I can not.
I checked the configuration and the settings are the same.
Can you help me?
Example: https://graph.facebook.com/860599774051206/?access_token=APP_ID|APP_SECRET
https://graph.facebook.com/860599774051206/notifications?template=#[860599774051206]test&access_token=APP_ID|APP_SECRET&method=post
the error is:
{ "error": { "message": "Unsupported post request. Object with ID
'860599774051206' does not exist, cannot be loaded due to missing
permissions, or does not support this operation. Please read the Graph
API documentation at developers.facebook.com/docs/graph-api",
"type": "GraphMethodException", "code": 100, "fbtrace_id":
"BRW7BqFeEER" } }
RESOLVED:
Any app can change the user_id
In an app the user_id is 962084030569446, in the other 860599774051206
Thakns for all.
I faced this issue when I was trying to post a response to an user from a page. I used the graph API me/accounts and got the list of pages. From there I retrieved the access_token of the page from which I'm going to post the response. I got the same error mentioned in the question.
The issue for me is the user account to which I was supposed to respond is locked due to security. This is the error I got from facebook when I tried to login
You can't use Facebook at the moment
This is the error I got for the post api call
{
"error": {
"message": "Unsupported post request. Object with ID 'xxx' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "yyy"
}
}
Once the account security is resolved, the issue is resolved.
While unrelated to the OP problem I thought I would contribute, I got this error when posting to the Offline Events endpoint https://graph.facebook.com/v2.8/<business_id>/events. I had posted from a node.js app successfully, then when porting the approach to a .Net implementation in our Linnworks order management system, got this error.
Turned out, I had mis-typed the access_token parameter that goes in the form data, i.e.
System.Collections.Specialized.NameValueCollection formFields = new System.Collections.Specialized.NameValueCollection();
formFields.Add("accessToken", accessToken);
formFields.Add("upload_tag", "store_data");
formFields.Add("data", data);
Should have been:
System.Collections.Specialized.NameValueCollection formFields = new System.Collections.Specialized.NameValueCollection();
formFields.Add("access_token", accessToken);
formFields.Add("upload_tag", "store_data");
formFields.Add("data", data);
Getting the access_token field wrong in this way caused this 'Object with ID does not exist' which is a bit of a red herring. I guess that, once the access_token value was not provided, no objects could be enumerated in our account because the request didn't authenticate in order to provide permissions, and so the object was 'not found'
(you do not have to use NameValueCollection, this is just a by-product of me using the multipart post implementation suggested here Upload files with HTTPWebrequest (multipart/form-data))
In my case - I had to use the app-id to get the list of pages using me/accounts.
Once I identify the page that I want to post the message to, I have to use the page-id to feed page-id/feed.
This solved the issue.
For example:
$response = $fb->get('/me/accounts', (string)$selBehRow1["fb_app_access_token"]);
foreach ($response->getDecodedBody() as $allPages)
{
foreach ($allPages as $page )
{
if (isset($page['id']) && $page['id'] == $selBehRow1['fb_page_id'])
{ // Suppose you save it as this variable
$appAccessToken = (string) $page['access_token'];
break;
}
}
}
$response = $fb->post(
//this is wrong: '/'.$selBehRow1["fb_app_id"].'/feed',
'/'.$selBehRow1["fb_page_id"].'/feed',
array(
"message" => "$msg",
"link" => "$link",
//"picture" => "http://www.example.net/images/example.png",
"name" => "$name",
"caption" => "$caption",
"description" => "$description"
),
$appAccessToken
);
}
i think post_id is wrong you can check it once
https://graph.facebook.com/860599774051206_4548643168486465/?access_token=APP_ID|APP_SECRET
https://developers.facebook.com/docs/graph-api/reference/v3.3/object/comments
use this api for replies to the post
Method: POST
https://graph.facebook.com/860599774051206_4548643168486465/comments?access_token=APP_ID|APP_SECRET
body:
{
"message": "Thanks"
}
You need to use GET request instead POST. Look at the documentation
In my case I needed to Complete Setup