Microsoft Graph does not retrieve the Group's Plan Id - json

After creating a Group using POST /v1.0/groups with the body:
{
"description": "hello",
"displayName": "group_for_restore",
"groupTypes": [
"Unified"
],
"mailEnabled": true,
"mailNickname": "group_for_restore",
"securityEnabled": false,
"visibility": "Public"
}
A request to GET /v1.0/groups/{group-id}/planner/plans does not retrieve any plans.
As far as I know, after creating a Group, a Plan will be created too. On the web interface you can see that this plan is correctly created and shown, but it does not appear in JSON response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.plannerPlan)",
"#odata.count": 0,
"value": []
}
After clicking on it in the web interface you can easily get the plan using the request above.
Is it ok to do such magic steps to fetch plan id?

The Web App is provisioning the Group's Plan the first time you attempt to access it. When creating a Group through the API however, you'll need to create a new Plan yourself:
POST https://graph.microsoft.com/v1.0/planner/plans
Content-type: application/json
{
"owner": "group-id",
"title": "title-value"
}
Keep in mind this important note from the documentation:
When creating a new plan, make a group its owner by simply setting the owner property on a plan object.

Related

Is there any documentation for EasyPost that shows the raw JSON for the requests, including headers? Or e.g. a PostMan collection?

I'm just doing the preparation for an integration with EasyPost's Shipping API, which will be server side C#, but we always build a PostMan collection for new integrations, so that we can test data separately from the application if there's an issue.
While I do love the fact that EP provide C# libraries and examples, I'm struggling to find anything that just gives me a list of required headers and the raw JSON format for the body of any requests. It feels a bit like they're just being a little too helpful.
I'll be looking at the Orders endpoint probably.
I've got an account, I've checked all their documentation and searched the internet but haven't found anything so I'm hoping I'm not the first developer to want to use a client application for testing outside my code.
Update:
EasyPost now does have a public workspace https://www.postman.com/easypost-api
with at least 1 public collection
The curl examples are basically the same as json:
For the Address creation example:
-d "address[street1]=417 MONTGOMERY ST"
is the equivalent of
{ "address": { "street1": "417 MONTGOMERY ST" } }
(you might have to escape some characters to be valid json).
Check out How to stimulate cURL request to a request using postman for postman with HTTP Basic Auth.
EasyPost does not provide a public Postman collection; however, here is an example of a shipment Postman body (raw) that could be used. You can adjust the values, actions, objects, etc to your needs.
Using the following, you shouldn't need to pass any headers. You'll pass your API key under the username field with the Basic Auth authorization type.
{
"shipment": {
"to_address": {
"id": "adr_123..."
},
"from_address": {
"id": "adr_123..."
},
"parcel": {
"id": "prcl_123..."
},
"carrier_accounts": {
"id": "ca_123..."
},
"options": {
"address_validation_level": "0"
}
},
"format": "json",
"controller": "shipments",
"action": "create"
}

How to get user timezone so we use it with Googlefit REST API?

When using Googlefit REST Aggregate API, we need to send startTimeMillis and endTimeMillis to get user's step data, for example.
{
"aggregateBy": [
{
"dataTypeName": "com.google.step_count.delta",
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
}
],
"startTimeMillis": 1568044800000,
"endTimeMillis": 1569004617000,
"bucketByTime": {
"period": {
"timeZoneId": "Europe/Madrid",
"type": "week",
"value": 1
}
}
The startTimeMillis and endTimeMillis params need to be sent according to the users' timezone, in our use case.
Does Googlefit REST API have an API to get the timezone of the device that sent that information? (I couldn't find it).
if not, what other strategies could we use to get the user's timezone. Does it exist this information in any other Google services API?
In the worst case scenario, we could send the users' location or timezone whenever they open our app, but I would like to avoid that, if possible.
Thanks.

GetResponse API v3 - Get contacts who open the newsletter

I'm having a hard time finding for the API in getting the contacts of the people who open the newsletter after sending it to a list of email. In the official API documentation of GetResponse, I didn't find a solution. Any idea or suggestion can help. thanks.
Though it's rather old now, I'll try to answer, maybe it helps someone.
Just as inside GetResponse web interface, you'll need to search contacts according to some criteria. These pages of the API docs describe how this is done:
http://apidocs.getresponse.com/v3/resources/search-contacts
Search contacts is the most complex part of the API. To save a search of contacts who opened a particular message you'll need to POST something like below to https://api.getresponse.com/v3/search-contacts/:
{
"name": "test_conditions", //can be any you like
"subscribersType": [
"subscribed" //can also be "undelivered", "removed" and "unconfirmed"
],
"sectionLogicOperator": "or", //or "and"
"section": [ //section can have up to 8 conditions; one saved search can have up to 4 sections
{
"campaignIdsList": [
"V" //you'll need to get campaigns' IDs with http://apidocs.getresponse.com/v3/resources/campaigns#campaigns.get.all
],
"logicOperator": "or",
"subscriberCycle": [
"receiving_autoresponder",
"not_receiving_autoresponder"
],
"subscriptionDate": "all_time", //"today", "yesterday", "this_month", "last_month", "this_week", "last_week" are also possible
"conditions": [
{
"conditionType": "opened",
"operatorType": "message_operator",
"operator": "autoresponder", //or "newsletter", or "split"
"value": "WTjXF" //message id, should be firstly got with a separate API call
}
]
}
]
}
More info on how the payload for such requests should be formed is here: http://apidocs.getresponse.com/v3/resources/search-contacts-reference
And the last point: if you don't need to save a search but only get the emails who've opened a message, in the object above you should remove the "name" property and post this to http://apidocs.getresponse.com/v3/search-contacts/contacts
More: http://apidocs.getresponse.com/v3/resources/search-contacts#search-contacts.contacts.form

Query sync gateway buckets using N1QL

I wanted to know if it's possible to query the sync gateway buckets using N1QL? Does it behave as a normal couchbase bucket or because of the metadata that sync gateway adds, is it possible to query it only through Rest APIs?
Currently I have a webhooks handler, which keeps a replica of the documents residing under sync gateway buckets. I need to do some aggrgations which need to be pushed back to clients. So, can I do all this heavy lifting directly trhough n1ql on sync gateway or using webhooks which does the aggregations and simply pushes the updated docs to sync gateway is the right option?
PS: The webhooks+Rest APIS option works perfectly for me currently. Just wanted to understand if this hop is necessary or not?
Yes, it is possible to query the sync gateway using N1QL - you just can't change it (update/delete/insert), as it would break the revisions' metadata.
You need to ignore the documents with IDs starting with _sync: and the _sync property of each document, which contains internal metadata. The remaining attributes are your usual document.
Example:
select db.* from db where meta().id not like '_sync:%'
Result:
[
{
"_sync": {
"history": {
"channels": [
null,
null
],
"parents": [
-1,
0
],
"revs": [
"1-b7a15ec4afbb8c4d95e2e897d0ec0a2e",
"2-919b17d3f418100df7298a12ef2a84bb"
]
},
"recent_sequences": [
6,
7
],
"rev": "2-919b17d3f418100df7298a12ef2a84bb",
"sequence": 7,
"time_saved": "2016-05-04T18:54:26.952202911Z"
},
"name": "Document with two revisions"
}
]
Ignoring the _sync attribute:
select name from db where meta().id not like '_sync:%'
Result:
[
{
"name": "Document with two revisions"
}
]
In Couchbase 4.5 (BETA as of today) we can use the object_remove function - although I'd avoid it in favor of the previous more explicit syntax.
select object_remove(db, '_sync') from db where meta().id not like '_sync:%'
Result:
[
{
"$1": {
"name": "Document with two revisions"
}
}
]
I don't know what's your setup currently, but AFAIK, it's perfectly fine to keep querying the bucket throught N1QL while using the REST API for the data changes.

Django REST Framework Batch PUT (Update)

I have implemented viewsets and routers, making an API that returns me some specific fields, I get the info correctly, and I can update (PUT) JUST ONE of the details in the JSON, one by one, and I need to update all of them at the same time.
I have this in my serializers.py
class OCompraDetalleSerializer(serializers.HyperlinkedModelSerializer):
# producto = ProductoSerializer(many=False)
item = serializers.RelatedField(source='producto.modelo')
descripcion = serializers.RelatedField(source='producto.descripcion')
unidad = serializers.RelatedField(source='producto.unidad')
# ocompra = OCompraSerializer(many = False)
class Meta:
model = OCompraDetalle
fields = ('url','item','descripcion','unidad','cantidad_ordenada','cantidad_recibida','fecha_entrega','precio','epc')
The API returns me this
HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS
[
{
"url": "http://localhost:8000/api/ocompradetalle/1/",
"item": "AANS/428375",
"descripcion": "SPLICING KIT SHIPPING ASSEMBLY",
"unidad": "PZA",
"cantidad_ordenada": "1",
"cantidad_recibida": "1",
"fecha_entrega": "2015-07-14",
"precio": "500",
"epc": "0320CAF425"
},
{
"url": "http://localhost:8000/api/ocompradetalle/5/",
"item": "AANS/53042",
"descripcion": "NOZZLE F-1/2 W/BLOW OFF CAP,LOCKWASHERS",
"unidad": "PZA",
"cantidad_ordenada": "5",
"cantidad_recibida": "0",
"fecha_entrega": "2015-07-14",
"precio": "300",
"epc": "0436F0BECD"
},
...
So the ALLOW section indicates that I CANT put, but if I open a single one detail, I get this:
HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
{
"url": "http://localhost:8000/api/ocompradetalle/1/",
"item": "AANS/428375",
"descripcion": "SPLICING KIT SHIPPING ASSEMBLY",
"unidad": "PZA",
"cantidad_ordenada": "1",
"cantidad_recibida": "1",
"fecha_entrega": "2015-07-14",
"precio": "500",
"epc": "0320CAF425"
}
Making it possible to UPDATE, my question is:
How can I PUT (Update) the whole JSON at the same time instead of making an Update for every single entry?
NOTE: the'item','descripcion','unidad' fields comes from another Model, thats why I have the ProductoSerializer commented, so I decided to include the specific values in the json.
NOTE 2: I only need to PUT or Update the cantidad_recibida value for every entry.
Django REST Framework does not allow for batch modifications to objects, but a package has been created that brings batch updating. Django REST Framework Bulk is a package that allows you to add a mixin to any generic view (including ViewSets) that can give it the ability to bulk create, update, or delete objects.
It can be made to work with routers with slight modifications. This should allow you to do what you are looking for.
NOTE 2: I only need to PUT or Update the cantidad_recibida value for every entry.
This sounds like you are looking for PATCH, though that doesn't allow for object creation in the same way that PUT allows.