Get Account ID in PUBG API - api

I'm trying to get a PUBG player's details using the Players developer API.
I'm aware that both the operations of this Players API require the account ID of the respective player, whose account details are required.
However, I tried my best to find the account ID (starting with account. and having 32 alphanumeric characters), but all in vain.
In this aspect, I've two specific questions:
How can I find my PUBG account ID?
If I want to fetch other players' details via API, how do I get their account ID programmatically? Or should I need to ask for their account ID explicitly?

Use filter[playerNames]=myPlayerName as shown in the player docs
On succes, it wil return a object containing the account_id;
https://api.pubg.com/shards/steam/players?filter[playerNames]=myPlayerName
{
"data": [
{
"type": "player",
"id": "account.c0e511111111111893af",
...
Replace myPlayerName with the username you're looking for.
edit;
This Community Manager says that only - and _ are allowed in nicknames, url-escaping won't be necessary!

Related

How to get user from User field LookupId

I have a list in sharepoint online.
And in this list, i have a person field.
When i call the API endpoint to get all the items in the list, i get an LookupId value for the person field.
I tried to get the user by using the value of the lookupid, but it don't work because the id is not recognized.
The lookupid is a int (eg: 21) instead of a guid.
Is there something missing in the configuration of the person field or in my calls to Microsoft Graph API ?
When a user signs into a SharePoint site collection for the first time, a ListItem is created in a hidden User Information List. The LookupId in a PersonOrGroup field refers to the ListItem in this list. The URL for the User Information List for SharePoint Online should be:
https://{yourTenant}.sharepoint.com/{yourSiteCollection}/_catalogs/users/detail.aspx
Since the User Information List is a generic SharePoint list, you can query the list via Graph. First, get the list id for the User Information List. An easy way to get the list id is to view the source for the User Information Site via Chrome and search for 'listId'. You should find a result like this:
"listId":"{yourListIdIsHere}"
Copy the id. By using the copied id, the id of your root site and the LookupId, you can get the ListItem in the User Information List:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{pasteCopiedListId}/items/{lookUpId}?$expand=Fields
The ListItem contains information about the user, such as the email, which can be used to identify the Azure user:
https://graph.microsoft.com/v1.0/users/{eMail}
Question: How could i get the hidden User Information List from Microsoft Graph?
If you do not want to use the 'trick' with Google Chrome to get the id, there is another way to get the site. Typically, if you want to get the id for any site, you would call:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists
However, you will not find the id of the User Information List, even if you include hidden sites. I do not know why. An additional problem seems to be, that you cannot filter lists by their name:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists?$filter=name eq 'users'
The query returns an error, that the provided filter statement is not supported. The only way to get the list without knowing the id seems to by using the property displayName of the list. However, the displayName is based on your localization. So, since I am from Germany, I can get the site by using the query:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists?$filter=displayName eq 'Benutzerinformationsliste'
You will need to replace Benutzerinformationsliste with your localized name. For EN replace it with 'User Information List'.
This returns the expected result:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('xxx')/lists(id,name,displayName)",
"value": [
{
"#odata.etag": "\"xxx\"",
"id": "xxx",
"name": "users",
"displayName": "Benutzerinformationsliste"
}
]
}
As you can see, the name of the list is 'users', so why the first filter statement does not work is a little mystery to me. Maybe someone here knows and can help out.
Some of the queries above don't work at the moment.
What I finally found as a good solution - after trying many many queries - is that you can do this by following the few steps below:
1- Get the GUID of the user information list.
Using the title of the list "User Information List" or the name "users" in the parameter "$filter" does not work.
Don't forget 'system' among the properties you select if you want to retrieve the hidden system-lists.
GET https://graph.microsoft.com/v1.0/sites('{site_id}')/lists?select=id,name,system
2- Filter the previous result in order to pick up the ID of the targeted list named 'users'.
By the way, applying this restriction "$filter=name eq 'users'" does not work.
You will get an exception. So you must do the filtering part by writing a few lines of code.
3- Once you've got the list identifier, then select all the items you want. And voilà! The word 'Fields' must be in pascal case (uppercase the first letter ).
GET https://graph.microsoft.com/v1.0/sites('{site_id}')/lists('users_list_id')/items?$select=Fields&$expand=Fields
As #QuestionsPS1991 mentioned, the people field in fact refers to the hidden user list. With the lookupid, we can get the user via below methods:
Get user by id
Get user property by expanding lookup field
//////////// updated
By default, MS Graph does not return this user list. You may hard code the list id or follow ##QuestionsPS1991 suggestion. Below is my test:

How can I create a device group in Cumulocity with REST

I am writing a service for forwarding our sensor data to Cumulocity platform. I designed the structure so that all the data is first sent to our main tenant and then device data for each customer is forwarded to corresponding tenants with Data Broker.
I can group devices manually and forward by group but I don't want to deal with it every time a new device is added.Sensor data contains customer name. Probably I can add customer name to device properties (like device_type) and use that as a filter but I want to avoid that if possible. So I thought, when a sensor data hits my endpoint, I do something like this:
Look if the device exists in the database.If it exists just publish measurement data.
If not look at the Group database(Just a key-value store containing customer names and managed Object Ids of the corresponding groups from Cumulocity) to see if there is entry for the customer.
If not add an entry and create a group with customer name.Then add the device to the group.
If it exists, just add the device to the group.
I tried adding devices to groups with REST and it works. The problem is I cannot create a device group with REST.
I looked at the Cumulocity API example requests and tried to tweak them a little.
I tried sending POST request to {{url}}/inventory/managedObjects as:
{
"name": "TestDeviceGroup",
"c8y_IsDeviceGroup": {}
}
It returns 201 created but I cannot see the group. When I try to get collection of groups I see it there as a managed object with a new Id.
I tried to add a new device to this object as a child asset.
{{url}}/inventory/managedObjects/{{GroupId}}/childAssets
{
"managedObject": "id:{{deviceId}}"
}
It returns 201 created but device GROUP is not updated.
If I recreate this scenario with a group created with UI and its Id everything works fine and device is added to the group.
As I understand what I create is not a legit device group and that is the main problem. So my question is How can I create device group with REST?
To create the group you were already on the right track you are just missing the correct type. Create your group like this:
POST /inventory/managedObjects
{
"name": "TestDeviceGroup",
"type": "c8y_DeviceGroup",
"c8y_IsDeviceGroup": {}
}
To assign your device to a particular group you can EITHER assign an existing device to an existing group like this (replace the placeholders in <> with your IDs):
POST /inventory/managedObjects/<groupId>/childAssets
{
"managedObject": {"id":"<deviceId>"}
}
Or you can directly create a new device into an existing group like this:
POST /inventory/managedObjects/<groupId>/childAssets
Content-Type: application/vnd.com.nsn.cumulocity.managedobject+json
{
"name": "my device",
"c8y_IsDevice": {}
}

How to retrieve orders list from Square using Square API V2

I'm attempting to get a list of recent transactions/orders from the Square Connect API V2 that lists out exactly what was purchased.
I tried the suggestion posted here:
How to retrieve Square orderIds for Call to BatchRetrieveORders
and received the error "Provided merchant_id and merchant_id in authorization do not match up."
I also attempted "v2/locations/(locationID)/orders/batch-retrieve" and received the error:
{
"success": false,
"message": {
"resource_bundle_name": "com.squareup.webservice.WebserviceMessages",
"key": "there.was.a.problem.processing.this.request",
"arguments": []
},
"debug_info": ""
}
I am able to get a list of transactions, but it isn't useful to me without the item information.
I'm using a personal account with the Personal Access Token.
This looks like a well-handled error in terms of its messaging. I suspect that the error message is telling you what you need to know. From this post, a Square employee mentioned that the cause is likely that you are:
using OAuth credentials for one merchant but attempting to retrieve data for another merchant. For example, if you have OAuth tokens for merchant A with location B but try to list payments for location token X that belongs to a different merchant Y, you will get this error.
You should validate that the token you're using is correct for the merchant you're trying to retrieve data for. If you're certain it's correct, I'd reach out to Square directly as there may be an issue with this token.

Instagram API error

I using Instagram API to get user info
api = InstagramAPI(access_token=access_token)
profile = api.user(user_id="kallaucyahoocojp") # I try to put output data to profile variable here
And I get the below error:
DownloadError: Unable to fetch URL: https://api.instagram.com/v1/users/kallaucyahoocojp.json?access_token=(u'1191812153.f78cd79.d2d99595c79d4c23a7994d85ea0d412c', {u'username': u'kallaucyahoocojp', u'bio': u'\u30c4\u30a4\u30c3\u30bf\u30d5\u30a9\u30ed\u30ef\u30fc\u5897\u52a0\u30b5\u30fc\u30d3\u30b9', u'website': u'http://twitter\u30d5\u30a9\u30ed\u30ef\u30fc.jp', u'profile_picture': u'http://images.ak.instagram.com/profiles/anonymousUser.jpg', u'full_name': u'Kallauc', u'id': u'1191812153'})
Can anybody help me to fix it?
You need to pass the numeric-based user id, rather than the username. For example, instead of passing kallaucyahoocojp, you might pass 1234 if t
Here's how to get the ID if you don't have it:
Search for the instagram user id using this endpoint. In the python api:
api.user_search(q="kallaucyahoocojp", count=100)
Check the results for an exact string match on each user name while iterating through the results (calling .lower() to be sure to ignore potential case issues).
If you don't find the user in the first page of results, call to the next page using the max id returned.
Get the user id object from the returned from the matching users search result, then call your original function again with the numeric id.
A couple of very important notes:
Notice that I called the search function for users with a count of 100. You can pick any number, but contrary to other SO posts, the first user is not always the user you want in a search. The search can and will match partials, and not always according to an exact match first. How do I know? I have production instagram apps. I will qualify and say that usually the results are in the first 2-3 matches. Decide what is cheaper; repeated API calls that bring you closer to the limit, or 1 large bulk call where you are certain to get all the results.
The python Instagram API last I checked does a terrible job returning paging information. You actually get the paging URL which defeats the purpose of the python API itself to get additional pages. Your options are extract the next id parameter from the URL using urlparse or something similar, or fix the API to return the paging data as an object per the json (I've done both). What happens is the API itself is discarding part of the json and only giving you the URL which normally you don't want/need.
In your example, here's the search response:
{
"meta": {
"code": 200
},
"data": [
{
"username": "kallaucyahoocojp",
"bio": "ツイッタフォロワー増加サービス",
"website": "http://twitterフォロワー.jp",
"profile_picture": "http://images.ak.instagram.com/profiles/anonymousUser.jpg",
"full_name": "Kallauc",
"id": "1191812153"
}
]
}
Revising your call:
api = InstagramAPI(access_token=access_token)
profile = api.user(user_id="1191812153")
I should note that you may not need to call the user call if you did a search because you may simply have all the info you need. It will depend on what you are doing of course, so I am giving you the general method to use the rest of the user api.
For extracting profile info using Instagram API, userid is required.
The endpoint for extracting userID:
https://api.instagram.com/v1/users/search?q=[username]&access_token=[HERE]
The endpoint for extracting profile info:
https://api.instagram.com/v1/users/[userid]/?access_token=[HERE]
Note that before extracting information, check the login permissions for your access token.

LinkedIn API people company

I would like to show the people numbers of a company. For that I display a result of a search.
I got a numResult but this number is not the real number of the company
IN.API.PeopleSearch()
.fields("id", "firstName", "lastName", "headline", "pictureUrl","location","public-profile-url")
.params({
"company-name": "Google",
"current-company": true,
"count": 8,
})
.result(function(result, metadata) {
setSearchResults(result, metadata);
});
}
Then I have result.numResults who is not the good number of the company. Someone has an idea?
I guess this is the number of the company about the user when he is connected.
You can retrieve specifics about companies, including the company size, from the Company API. The specific field that contains the size range for the company is employee-count-range.
In terms of accessing the data via the JavaScript API, consider using the IN.API.Raw() method.