How to share location with public tag with Glympse REST API - glympse

I am trying to share a location to a public tag in Glympse with their REST API. My application is creating a ticket with
/v2/users/self/create_ticket
After that I am trying to add that ticket to the public tag/group (which is already available).
/v2/tickets/${ticketid}/append_data
{
[
"t": ${timestamp},
"pid": 0,
"n": "card_id",
"v": card_id // I am putting the group ID here
]
}
After that I have no clue how to proceed. I find the Glympse API description very confusing, so I tried several API functions but none of them worked, like updating the card
/v2/cards/${groupdid}/ticket
error: { result: 'failure', response: {}, meta: { error: 'invalid_access',
error_detail: 'Error processing request',
time: 1506944558077 } }
or simply just adding location data (no error but nothing visible in the tag)
/v2/tickets/${ticketid}/append_location.
Can you help me with the flow how to share the data to a public tag? I cannot find anything like that for the REST API. I could find this link: https://developer.glympse.com/docs/core/client-sdk/guides/common/groups but it does not help me with JavaScript and REST.
Thank you

Cards are only for private groups. To share to a public group (public tag) after you create the ticket, you create an invite of type "group" where the address is the name of the tag.
https://developer.glympse.com/docs/core/api/reference/tickets/id/create_invite/post
The group type appears to be missing from that reference page, but that is the type to use.
For example, to share to a tag named "testtag123":
tickets/[ticket_id]/create_invite?locale=en_US&region=en_US&type=group&send=server&address=testtag123&name=testtag123

Related

Get Blocked Users with GitHub GraphQL

I stumbled on GitHub GraphQL today and at first glance, it seemed to me I could do more with it than I already do with their regular RESTful API. I created some Adapters in my existing application and managed to authenticate Users based on a Personal Access Token without much trouble.
Going further, I tried then list Followers, Followees and Blocked Users:
query GetFollowers {
user(login: "username") {
followers(first: 100) {
nodes {
login
name
avatarUrl
}
}
}
}
Obviously, replacing username with a real GitHub username
However, I couldn't find a way to list the Blocked Users, which is something I can do with the RESTful API. Reading the (extensive) documentation, the closest I could build was:
query GetBlockedUsers {
node(id: "node_id") {
... on UserBlockedEvent {
subject {
avatarUrl
login
name
}
}
}
}
This not only didn't work — or, at least, didn't yield any results — but would also require an extra step when requesting the endpoint, as I would first need to retrieve the node_id of a given username:
Yes, there are some Users blocked on my list :Þ
query GetUserID {
user(login: "username") {
id
}
}
Is it possible to list/add/remove Users to the Blocked List with their GraphQL API? Preferably, but not required, in one single query, filtering by username instead of this node_id
Thank you for your time :D

Post data to custom AL field in Business Central

I am trying to create an API call to add data into a custom field that was created on the Sales Order page using AL Extensions. The issue is when I try to do the api call through postman, I am getting "The Property "propertyName" does not exist on type 'Microsoft.NAV.salesOrder'". First of all, I don't even know if the API allows for this, so is it even possible? And secondly, if it is possible, is there a certain way to set up the API call or the Field through the AL Extension?
tableextension 50100 "AddProjectIdToSalesOrder" extends "Sales Header"
{
fields
{
field(50100; "CrmProjectId"; Guid)
{
Caption = 'Crm Project Id';
DataClassification = OrganizationIdentifiableInformation;
}
}
}
pageextension 50100 "AddProjectIdToSalesOrder" extends "Sales Order"
{
layout
{
addlast(General)
{
field("CRM Project Id"; Rec.CrmProjectId)
{
ApplicationArea = all;
ToolTip = 'The Guid of the related Project Record in the CRM environment';
}
}
}
}
This is how I am setting up the field with the AL extension, and for the post call, I am just creating a new Sales Order with a post and the body looks like:
{
"customerNumber" : "10000",
"CrmProjectId" : "random-guid"
}
And the error is "Bad Request": "The property 'CrmProjectId' does not exist on type 'Microsoft.NAV.salesOrder'. Make sure to only use property names that are defined by the type." Any help would be appreciated.
The Sales Order API is a separate page. It is not equivalent to the Sales Order page so you have to modify the API to accomplish what you want.
However the standard API's provided by Microsoft can't be extended.
You are left with two options:
Make a copy of the standard Sales Order API (this involves making a copy of all the linked APIs as well e.g. the Sales Line API).
Create a new API page with the single purpose of updating your new field. Then you would use the standard Sales Order API to create the Sales Order and then update CrmProjectId with a second call to your custom API page.

Microsoft 365 API : Issue at attaching Contact to Campaign Response

I am trying to attach a contact to campaign response.
I am using rest API for that.
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/web-api/campaignresponse?view=dynamics-ce-odata-9
Post Data :
{
"firstname": "TestFirst",
"lastname": "TestLast",
"emailaddress": "test#test.com",
"telephone": "1234567890",
"prioritycode": 0,
"responsecode": 1,
"subject": "Test Subject",
"statuscode": 1,
"regardingobjectid_campaign#odata.bind": "/campaigns(xxxx90c-11ef-e811-a966-000d3ad24a0d)",
"regardingobjectid_contact#odata.bind": "/contacts(xxxxfa2e-c3b5-e811-a962-000d3ad24a0d)"
}
Here is my JSON.
I am getting Error : “Campaign as RegardingObject must be supplied”. Without contact, it works fine.
I had the same problem and the documentation is not very clear about it, I had to check all the relationships of the CampaignResponse in order to understand how to solve this.
If you want to create a CampaignResponse linked to both a Campaign and a Contact you need to do the following:
Create a CampaignResponse with the "regardingobjectid_campaign#odata.bind" in the params sent.
POST "https://some_subdomain.crm6.dynamics.com/api/data/v9.0/campaignresponses"
{
"regardingobjectid_campaign#odata.bind": "/campaigns(CAMPAIGN_ID_HERE)",
"description": "some desc",
"subject": "some subject "
}
Then find the CampaignResponse you just created to get its activityid (every CampaignResponse is an Activity)
Finally, you need to create a new ActivityParty, that will link the Contact to the CampaignResponse.
POST "https://some_subdomain.crm6.dynamics.com/api/data/v9.0/campaignresponses(CAMPAIGN_ID_HERE)/activitypointer_activity_parties"
{
"partyid_contact#odata.bind": "/contacts(CONTACT_ID_HERE)",
"participationtypemask": 11 //this is the code for customers
}
The "Regarding" lookup field can only be set to a single "regarding" record. Even though it appears that there are different Regarding fields, one for each entity type, those are "helper" fields that let you easily set the main Regarding field by setting one of those regardingobjectid_xxx fields.
You must choose to use either a campaign or a contact as your Regarding field. You can of course create other lookups, so you could use the Regarding field for your campaign and then add an additional Contact lookup field, for example.

Map HATEOAS links to actual API links

I'm trying to implement a HATEOAS Rest Client using Spring Boot.
Right now, I'm stuck in a point where I need to convert HATEOAS into an actual API URI.
If I post a new object of type Customer like:
{
"name": "Frank",
"address": "http://localhost:8080/address/23"
}
And then I retrieved with a request to http://localhost:8080/api/customer/1`, HATEOAS gives me something like
{
"name": Frank,
"_links": {
"address": {
"href": "http://localhost:8080/api/customer/1/address"
}
}
}
Is it possible to convert a link of the form of http://localhost:8080/api/customer/1/address to an API call like http://localhost:8080/api/address/23 ?
If you see what HATEOS returns after you say,
GET: http://localhost:8080/api/customer/1
is
{
"name": Frank,
"_links": {
"address": {
"href": "http://localhost:8080/api/customer/1/address"
}
}
}
According to Understanding HATEOS,
It's possible to build more complex relationships. With HATEOAS, the output makes it
easy to glean how to interact with the service without looking up a specification or
other external document
which means,
after you have received resource details with
http://localhost:8080/api/customer/1
what other operations are possible with the received resource those will be shown for easier/click thru access to your service/application,
here in this case HATEOS could find a link http://localhost:8080/api/customer/1/address that was accessible once you have customer/1 and from there if you want then without going anywhere else customer/1 's address could be found with /customer/1/address.
Similarly if you have /customer/1's occupation details then there would be another link below address link called http://localhost:8080/api/customer/1/occupation.
So if address is dependent on customer i.e. there can be no address without customer then your API endpoint has to be /api/customer/1/address and not directly /api/address/23.
However, after understanding these standards and logic behind HATEOS's such responses if you still want to go with your own links that may not align with HATEOS's logic you can use,
Link Object provided by LinkBuilder interface of HATEOS.
Example:
With object of type Customer like:
Customer c = new Customer( /*parameters*/ );
Link link= linkTo(AnyController.class).slash("address").slash(addressId);
customer.add(link);
//considering you want to add link `http://localhost:8080/api/address/23` and `23 is your addressID`.
Also you can create a list of Links and keep adding many such links to that list and then add that list to your object.
Hope this helps you !

Unable to get gender from Google People API

I've got a problem obtaining gender information from People API.
I'm making a request to https://people.googleapis.com/v1/people/account_id which is not returning gender field. If I add genders to personFields it is giving me Requested entity was not found error.
It looks like obtaining this information is forbidden. Is there any chance to get this field?
There are two ways to use the Google People api.
The first assumes that you have used Oauth2 to authenticate your user.
GET https://people.googleapis.com/v1/people/me
returns the info about the current authenticated user.
The second is a public call to the api. you can use an API key or Oauth2.
GET https://people.googleapis.com/v1/people/117200475532672775346
This will return the info about a specific user {117200475532672775346} but it will depend upon what that user has set to public. The above number is my personal g+ account, the following is the gender response.
"genders": [
{
"metadata": {
"primary": true,
"source": {
"type": "PROFILE",
"id": "117200475532672775346"
}
},
"value": "female",
"formattedValue": "Female"
}
I have no idea where you are getting your account id this is a users google id. The information must be filled out on Google plus i suggest you check the users google+ account to see what they have set to public https://plus.google.com/u/0/117200475532672775346. Note: It doesn't matter if this is the current authenticated user if they dont have the info set public you cant see it in your application.
Tip: assuming you only want to see genders you can use the fields parameter to request just that
?fields=genders

Resources