Get zabbix graph to png via API - bash

I have a login script as follows:
curl --location --request POST 'https://zabbixUrl.com/api_jsonrpc.php' \
--header 'Authorization: Basic bWlndWVsLmh1cnRhZG86MTczM295ZmQxVg==' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "user",
"password": "pass"
},
"id": 1
}'
Which returns:
{"jsonrpc":"2.0","result":"1g1hd43j4d3jd4jsl4n35b4211n1d2e2","id":1}
With this Api token (result), I can execute all the Zabbix's methods, for instance:
curl --location --request POST 'https://zabbixUrl.com/api_jsonrpc.php' \
--header 'Authorization: Basic bWlndWVsLmh1cnRhZG86MTczM295ZmQxVg==' \
--header 'Content-Type: application/json' \
--data-raw '
{
"jsonrpc": "2.0",
"method": "screenitem.get",
"params": {
"output": "extend",
"screenids": "258"
},
"auth": "1g1hd43j4d3jd4jsl4n35b4211n1d2e2",
"id": 1
}'
Now I am trying to obtain a graph in PNG format. I can view this graph in PNG format after inserting the user and pass in the intermediate screen:
Now what I am trying to do is to get this PNG graph via API. My approach is the following (ps: the url included is the same one as the one used on the browser, where it does work):
curl --header 'Authorization: Basic bWlndWVsLmh1cnRhZG86MTczM295ZmQxVg==' --data-raw 'auth:1g1hd43j4d3jd4jsl4n35b4211n1d2e2' http://zabbixUrl.com/chart2.php?graphid=123456&period=604800&stime=1614012539
Using this form, I get a 401 error. I guess that it is not correctly detecting the token.
Therefore, my question is, how can I obtain the PNG of this Zabbix's graph via API? How can I do it so it correctly detects the token?

When you authenticate to the API you use a token, when you authenticate to the GUI you need a cookie. Using curl, you need the --cookie option, see Save cookies between two curl requests.
In python requests, you would use a Session: see zabbix-gnomes's zgetgraph.py for a python solution.
A working example in Zabbix 5.0:
auth=$(curl -s --data '{ "jsonrpc": "2.0", "method": "user.login", "params": { "user": "...", "password": "..." }, "id": 1 }' --header 'Content-Type: application/json' https://.../zabbix/api_jsonrpc.php | jq -r .result)
curl --cookie "zbx_sessionid=$auth" "https://.../zabbix/chart2.php?graphid=517&from=now-2d&to=now&height=201&width=1717&profileIdx=web.charts.filter&_=up0bkgs0" -o file.png

I found the solution:
import requests
import json
import shutil
​
##### GET CREDENTIALS #####
​
USER = "user"
PASSWORD = "pass"
URL_AUTH = "https://url.com/api_jsonrpc.php"
HEADER_AUTH = {
'Authorization': 'Basic bWlndWVsLmh1cnRhZG86MTczM295ZmQxVg==',
'Content-Type': 'application/json',
}
DATA_AUTH = """
{
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "%s",
"password": "%s",
"userData": true
},
"id": 1
}
""" % (USER, PASSWORD)
respAuth = requests.post(URL_AUTH, headers=HEADER_AUTH, data=DATA_AUTH)
zabbixSessionId = json.loads(respAuth.content.decode('utf8').replace("'", '"'))["result"]["sessionid"]
##### GET PNG #####
URL_CHART = "https://url.com/chart2.php?graphid=12345&period=7200"
HEADER_CHART = {
'Authorization': 'Basic bWlndWVsLmh1cnRhZG86MTczM295ZmQxVg==',
'Content-Type': 'image/png',
'Cookie': 'zbx_sessionid=%s' % (zabbixSessionId)
}
PNG_PATH = "./image.png"
respChart = requests.request("POST", URL_CHART, headers=HEADER_CHART, stream=True)
with open(PNG_PATH, 'wb') as out_file:
shutil.copyfileobj(respChart.raw, out_file)

Related

Issuecommand RESET_PASSWORD on android management api doesn't change lock code of the device et LOCK_NOW flag doesn't lock the device either

I'm trying to reset the lock code of my device through android management API but it seems that RESET_PASSWORD doesn't do anything. The endpoint is https://androidmanagement.googleapis.com/v1/enterprises/entrepriseID/devices/deviceID:issueCommand and my payload looks like this
{
"type": "RESET_PASSWORD" ,
"duration": "600s",
"newPassword":"1234",
"resetPasswordFlags":["LOCK_NOW"]
}
Does anyone find any solution ?
I have the same problem with this command :
I find the command in the documentation.
When i execute this CURL, it answer me 200 OK.
curl --location --request POST 'https://androidmanagement.googleapis.com/v1/enterprises/<enterprise>/devices/<device_id>:issueCommand' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"type": "RESET_PASSWORD",
"duration": "600s"
}'
{
"name": "enterprises/<enterprise>/devices/<device_id>/operations/<operation_id>",
"metadata": {
"#type": "type.googleapis.com/google.android.devicemanagement.v1.Command",
"type": "RESET_PASSWORD",
"createTime": "2022-05-03T09:34:15.913Z",
"duration": "600s",
"userName": "enterprises/<enterprise>/users/<user_id>"
}
}
But, when i try to get the health of the operation, it answer to me an error:
curl --location --request GET 'https://androidmanagement.googleapis.com/v1/enterprises/<enterprise>/devices/<device_id>/operations/<operation_id>' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer <TOKEN>'
Answer (200 OK):
{
"name": "enterprises/<enterprise>/devices/<device_id>/operations/<operation_id>",
"metadata": {
"#type": "type.googleapis.com/google.android.devicemanagement.v1.Command",
"type": "RESET_PASSWORD",
"createTime": "2022-05-03T09:34:15.913Z",
"duration": "600s",
"errorCode": "INVALID_VALUE",
"userName": "enterprises/<enterprise>/users/<user_id>"
},
"done": true,
"error": {
"code": 3
}
}
i don't know which invalid value i put into the params..
More, the LOCK or REBOOT command work correctly without any error for the same device.
Sincerely.
Adrien.
I tried to recreate the scenario using the same settings that you are using and I was able to reset my password and change it to the new password.
device_name = enterprise_name + '/devices/deviceId'
device_json = '''
{
"duration": "600s",
"type": "RESET_PASSWORD",
"newPassword": "12345",
"resetPasswordFlags": [
"LOCK_NOW"
]
}
'''
androidmanagement.enterprises().devices().issueCommand(
name=device_name,
body=json.loads(device_json)
).execute()
This API seems to be working properly in my end. For this API to work properly, please make sure the newPassword value meets any passwordRequirements you have set in the policy. Also, you can check the device if it receives the command as it should lock its screen automatically upon receiving the command.
You can also try using other commands to ensure that the issue is not in your device or connection.

Square Insufficient permissions to set app_fee_money when creating a payment

I used Square Oauth to obtain merchant_access_token using the scopes
CUSTOMERS_WRITE
CUSTOMERS_READ
ITEMS_WRITE
ITEMS_READ
MERCHANT_PROFILE_WRITE
MERCHANT_PROFILE_READ
ORDERS_WRITE+ORDERS_READ
PAYMENTS_WRITE
PAYMENTS_READ
PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS
from https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees
When I run the command, I get Insufficient permissions to set app_fee_money
I tried this from both the Application as well as Postman
What am I doing wrong?
curl --location --request POST 'https://connect.squareupsandbox.com/v2/payments' \
--header 'Square-Version: 2021-01-21' \
--header 'Authorization: Bearer merchant_access_token' \
--header 'Content-Type: application/json' \
--data-raw '{
"source_id": "ccof:customer-card-id-ok",
"idempotency_key": "6726cbd2-7893-4cc3-908e-c54731e9f1fe77979",
"amount_money": {
"amount": 5000,
"currency": "USD"
},
"app_fee_money": {
"amount": 1220,
"currency": "USD"
},
"customer_id": "676YFJE8CCRPZ2K7F9C155JYP8",
"location_id": "LG5CC4T0JXCX9", //Merchant location id
"order_id": "M4C0LcxaW6DNpbyxE7sLypvbFA8zb4F",
"reference_id": "M4C0LcxaW6DNpbyxE7sLypvbFA8zb4F",
"statement_description_identifier": "Organization name",
"note": "Fee note"
}'
PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS was in the code but older version of scopes without it was running, that fixed it. Thanks #sjosey

How to send a message to a channel of MS Team using Graph API

How to send a message to a channel of MS Team using Graph APÌ?
I have used below commands to generate token for grant_type client_credentials.
curl --location --request POST 'https://login.microsoftonline.com/{tenant_ID}/oauth2/v2.0/token' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials' --data-urlencode 'client_id={client_id}' --data-urlencode 'client_secret={client_secret}' --data-urlencode 'scope=https://graph.microsoft.com/.default'
Then using token generated i ran following curl command to get list of channels and it run successfully.
curl --location --request GET 'https://graph.microsoft.com/v1.0/teams/{team_ID}/channels/' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IjBMa0VQY1V4RjgxWnJOTnlUb2Z1SUFRc2VEVUYwQ25wa3pPcWFiY2wwcjgiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCIsImtpZCI6ImtnMkxZ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NzAxLTRhYmUtYjJiNi1iMDRlZmVkYWFlODUiLCJ0ZW5hbnRfcmVnaW9uX3Njb3BlIjoiQVMiLCJ0aWQiOiJlODZiZjgyMS1kNmVhLTQ1MTAtOGZmYi03YzY4NmM2NDU3ZjIiLCJ1dGkiOiJUUHo5bkNvNU8wU2o2R2FYaDZvWEFBIiwidmVyIjoiMS4wIiwieG1zX3RjZHQiOjE1OTQ2MjgyNTZ9.NyL_Pf26Xq7ciHP241A8hSxqj2pqgLJSGfGngBdauAmHeFCbxxPQJPGN1OgyFqn_RS5flIgFAtqDU7bEJhuVemYWhngi2Yj-Yu3FCptFwWhpIHp03IeChbjX1CVIR1ESHuCFiH_EQSXAdk9spPB8iW8Yzp5q2gwVwWhxQgbdixXZ-lzT6f6TTBCQqkPkazMFwUxEHQtDXEQfYjdNu5V3W4in1PM5I4EKdo_tw7H4qMG4aImCGtVnX4P_jVEHPkk_8888glqPLmABpd7P6PGxnyirSFox60UFYT2ISe2Xqh5MwE0fGUyEKc_-0MHubmVfm6qbnz_TiZAYqiteZVwmSg'
Below is the response
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('e76f9b0b')/channels",
"#odata.count": 3,
"value": [
{
"id": "19:d893c#thread.tacv2",
"displayName": "General",
"description": null,
"isFavoriteByDefault": null,
"email": "",
"webUrl": "https://teams.microsoft.com/l/channel/19%3a%40thread.tacv2/General?groupId=e76f9b0b-b6d3&tenantId=e86bf",
"membershipType": "standard"
},
{
"id": "19:44e0b#thread.tacv2",
"displayName": "apiSec-Issues",
"description": null,
"isFavoriteByDefault": null,
"email": "",
"webUrl": "https://teams.microsoft.com/l/channel/19%3b0b%40thread.tacv2/apiSec-Issues?groupId=e76f9b0b-b6d3&tenantId=e86bf821-d6ea-4510",
"membershipType": "standard"
},
{
"id": "19:721251965a30#thread.tacv2",
"displayName": "Dev",
"description": "This channel is where we debate all future development plans",
"isFavoriteByDefault": null,
"email": "",
"webUrl": "https://teams.microsoft.com/l/channel/19%330%40thread.tacv2/Dev?groupId=e76f9b0b-b6d3-42bb-baf1-6a798e4&tenantId=e86bf821-d6ea-4510-8ffb-7c686c64",
"membershipType": "standard"
}
]
}
However it throws unauthorized error when tried to post/sent a message to a channel using token generated from above mention curl command
curl --location --request POST 'https://graph.microsoft.com/v1.0/teams/{team_ID}/channels/{channel_ID}/messages/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IlRiYnhpOWlNZWZaTUZOaDNhNERIVDdlakNheU5QR1V2X3RhYzdwM3hxMVEiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCIsImtpZCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCJ9.eyJhdWQiOiJodHRwczovL2dyYXBoLm1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9lODZiZjgyMS1kNmVhLTQ1MTAtOGZmYi03YzY4NmM2NDU3ZjIvIiwiaWF0IjoxNjA1MzU4MDY4LCJuYmYiOjE2MDUzNTgwNjgsImV4cCI6MTYwNTM2MTk2OCwiYWlvIjoiRTJSZ1lQRHFkS2g5ekN1ZlVMYklWME12NGlZM0FBPT0iLCJhcHBfZGlzcGxheW5hbWUiOiJmeHRlc3QiLCJhcHBpZCI6ImVmYWQzZjlhLWY4MmQtNGNkMS05OTE1LTIwNDA0YjQ2NmYzNyIsImFwcGlkYWNyIjoiMSIsImlkcCI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2U4NmJmODIxLWQ2ZWEtNDUxMC04ZmZiLTdjNjg2YzY0NTdmMi8iLCJpZHR5cCI6ImFwcCIsIm9pZCI6Ijc2ZmQwM2FlLTE3MDEtNGFiZS1iMmI2LWIwNGVmZWRhYWU4NSIsInJoIjoiMC5BQUFBSWZocjZPcldFRVdQLTN4b2JHUlg4cG9fcmU4dC1ORk1tUlVnUUV0R2J6ZFRBQUEuIiwic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UmVhZFdyaXRlLkFsbCIsIk5vdGVzLlJlYWRXcml0ZS5BbGwiLCJBcHByb3ZhbFJlcXVlc3QuUmVhZC5FbnRpdGxlbWVudE1hbmFnZW1lbnQiLCJEZXZpY2VNYW5hZ2VtZW50UkJBQy5SZWFkV3JpdGUuQWxsIiwiVHJ1c3RGcmFtZXdvcmtLZXlTZXQuUmVhZC5BbGwiLCJQb2xpY3kuUmVhZFdyaXRlLkZlYXR1cmVSb2xsb3V0IiwiUG9saWN5LlJlYWRXcml0ZS5UcnVzdEZyYW1ld29yayIsIlByaXZpbGVnZWRBY2Nlc3MuUmVhZFdyaXRlLkF6dXJlQURHcm91cCJdLCJzdWIiOiI3NmZkMDNhZS0xNzAxLTRhYmUtYjJiNi1iMDRlZmVkYWFlODUiLCJ0ZW5hbnRfcmVnaW9uX3Njb3BlIjoiQVMiLCJ0aWQiOiJlODZiZjgyMS1kNmVhLTQ1MTAtOGZmYi03YzY4NmM2NDU3ZjIiLCJ1dGkiOiJISVZzMmoxUl8wNmJhNjZuSzRRTEFBIiwidmVyIjoiMS4wIiwieG1zX3RjZHQiOjE1OTQ2MjgyNTZ9.a2gPsNyiJxNn3gD1WgibPuD55VC1hxirBkHjMa5xIn242AJJ2bpITcuun3glSSel9rHefmVEnqV9UXkSeq4OJTMGL-XrzZSUw09EkbKxOIq9FqWIJLe_LZS54to6xM62z4V-3YrNSHS9dUsQXRRoaeTe6_n_zzdx_epFtvoNiKnxmSggMN1Ly8yBJPitDpZsqjLtIRWcLRnARFD-_A8VkBjGr2k4KWTlcFlt7ltPDRfqEio7FNpRq4-B_4M14JuDEPAybdoJKXoyg87bFUmNMFf-lPnEmxNuHcUmYU3iy8ZJnX6SU1vCZwln0dQMUb_U7sOI796af7g8INksxVAwCA' \
--data-raw '{
"body": {
"content": "Hello World"
}
}'
In response it throws Unauthorized Error
{
"error": {
"code": "Unauthorized",
"message": "Unauthorized",
"innerError": {
"date": "2020-11-14T12:54:36",
"request-id": "d2e6aaa7-2884-4e4d-bd71-b92038b",
"client-request-id": "d2e6aaa7-2884-4e4d-bd71"
}
}
}
Just to get this working for testing purpose, i have given all permissions for delegated and application(About 442 permissions) with admin consent but still response throws "Unauthorized Error"
So can someone help out over here, where am i getting it wrong.
What is right procedure to send a message to channel of a MS team using MS-Graph-api or what else needs to be enable/done which i am forgetting over here, to get this working.
Only delegated permission will work in this scenario & not the application permissions. Make sure you have the following permissions - ChannelMessage.Send, Group.ReadWrite.All - as one of the permissions is required to call this API.
Just to isolate the above issue, test the same Graph API call, with
the above said permissions in Microsoft Graph explorer and see if you
can able to send message to channel or not. Here's the doc.
Based on that you used grant_type as authorization code to send messages to a channel successfully.
Use grant_type as authorization code for sending messages to a channel as grant_type client_credentials is not supported in delegated permission as pointed out on this link as well https://developer.microsoft.com/en-us/graph/blogs/30daysmsgraph-day-12-authentication-and-authorization-scenarios/
For others to move forward follow above link to get the authorization code and use it to generate bearer access token to send messages to a channel
Delegated permissions required to generate bearer access token: "openid profile User.Read email"
To Generate access-token
curl --location --request POST 'https://login.microsoftonline.com/<Tenant_ID>/oauth2/v2.0/token' --header 'Content-Type: application/x-www-form-urlencoded' --header 'Cookie: x-ms-gateway-slice=prod; stsservicecookie=ests; fpc=AiMjowz5Jo5EvQyTMhzOqaQ9npEsAQAAAOMFRtcOAAAAqSBP-gEAAABXBkbXDgAAAA' --data-urlencode 'client_id=<client_ID>' --data-urlencode 'client_secret=<client_secret>' --data-urlencode 'redirect_uri=http://localhost' --data-urlencode 'grant_type=authorization_code' --data-urlencode 'scope=openid profile offline_access User.Read' --data-urlencode 'code=0.AAAAIfhr6OrWEEWP-3xobGRX8hpZv2PH4fVJh6PLsdEHaztTAOY.AQABAAIAAAB2UyzwtQEKR7-rWbgdcBZIMB3WJhW2dvCBgjVNf-tzDc_9Yc7YnN1JrIZtaE8b0L4RylYkzJkGWZAcxeTrMDhhjrjCJDGMOjkLPf8Jd0lLX6C7tFOU-RRg1tNDds0kI1RDdRJRYBMVFOr_riKgCw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tDfGhYyzxiPe7Itu1od31M83y6H7ZOC9XVkQrI9jrt_Jn3wTwqRjFuwWwpCxK2iAc6y3pskgAA'
Below will be the response
{
"token_type": "Bearer",
"scope": "ChannelMessage.Send Group.ReadWrite.All openid profile User.Read email",
"expires_in": 3599,
"ext_expires_in": 3599,
"access_token": "eyJ0eXAiOiJKV1QiLCJub25jZSI6IloxNG9xVEI5cjFYcldGZUJQQzNjU0VwR2p3aXlpUUZPVC1hTXBsaTZrMFkiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCIsImtpZCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9lODZiZjgyMS1kNmVhLTQ1MTAtOGZmYi03YzY4NmM2NDU3ZjIvIiwiaWF0IjoxNjA1NjM1NjI3LCJuYmYiOjE2MDU2MzU2MjcsImV4cCI6MTYwNTYzOTUyNywiYWNjdCI6MCwiYWNyIjoiMSIsImFjcnMiOlsidXJuOnVzZXI6cmVnaXN0ZXJzZWN1cml0eWluZm8iLCJ1cm46bWljcm9zb2Z0OnJlcTEiLCJ1cm46bWljcm9zb2Z0OnJlcTIiLCJ1cm46bWljcm9zb2Z0OnJlcTMiXSwiYWlvIjoiQVVRQXUvOFJBQUFBcHNITXZZdm9GNXY3Y2pFUkNjRWM4NllCM2tEejhXNWEyOW5pSXlkalhxNWFsMUYzTm9uRVQ0d0UvQXI5QVFYUkZzRy81eHdBV2kyU1BTcm9mUHdtYnc9PSIsImFsdHNlY2lkIjoiMTpsaXZlLmNvbTowMDAzNDAwMUQ1OEQ3Qjg3IiwiYW1yIjpbInB3ZCJdLCJhcHBfZGlzcGxheW5hbWUiOiJ0ZXN0LW1zdGVhbSIsImFwcGlkIjoiNjNiZjU5MWEtZTFjNy00OWY1L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zbYN3IskuAN5lNXeTdV0xrra9FdvMolrRdMT9Bt14-QG8za4OoWDTb-s5Bq8kZUrhiVkKP4GowRYWBLFXxKThrPE4zQK6EJREMbmBTHy3nrxF_smNqQjCwE95T0qBAnPC6hQQEXO_U_J3EcAD9hPB-bzFiR3nIs6rK_MEinwcSs6QEgl4CDOxw"
}
To Send message to a channel
Delegated permissions required to send message: "ChannelMessage.Send Group.ReadWrite.All"
curl --location --request POST 'https://graph.microsoft.com/beta/teams/team_ID/channels/channel_ID/messages' --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IloxNG9xVEI5cjFYcldGZUJQQzNjU0VwR2p3aXlpUUZPVC1hTXBsaTZrMFkiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCIsImtpZCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9lODZiZjgyMS1kNmVhLTQ1MTAtOGZmYi03YzY4NmM2NDU3ZjIvIiwiaWF0IjoxNjA1NjM1NjI3LCJuYmYiOjE2MDU2MzU2MjcsImV4cCI6MTYwNTYzOTUyNywiYWNjdCI6MCwiYWNyIjoiMSIsImFjcnMiOlsidXJuOnVzZXI6cmVnaXN0ZXJzZWN1cml0eWluZm8iLCJ1cm46bWljcm9zb2Z0OnJlcTEiLCJ1cm46bWljcm9zb2Z0OnJlcTIiLCJ1cm46bWljcm9zb2Z0OnJlcTMiXSwiYWlvIjoiQVVRQXUvOFJBQUFBcHNITXZZdm9GNXY3Y2pFUkNjRWM4NllCM2tEejhXNWEyOW5pSXlkalhxNWFsMUYzTm9uRVQ0d0UvQXI5QVFYUkZzRy81eHdBV2kyU1BTcm9mUHdtYnc9PSIsImFsdHNlY2lkIjoiMTpsaXZlLmNvbTowMDAzND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TAiLCJiNzlmYmY0ZC0zZWY5LTQ2ODktODE0My03NmIxOTRlODU1MDkiXSwieG1zX3N0Ijp7InN1YiI6ImhSM3M0ZHJ1THBjanhCU091SG43RzNGSmdQMjNSQlh3QmpEeF9hN3d5ZWMifSwieG1zX3RjZHQiOjE1OTQ2MjgyNTZ9.SDn4NIiHLxvGp0odn7C_hXZ0juSsgnyE_Dc0uTwMK_jP_n7-SjisYfw1vOoX7st5-C27_HwLoSWxUt1cqL7ENcrt_7HXvZSwFsXVN4JCeEOVZUZUzUakcmttUISPPPygLhv4-EPD-sBC8TDs9ncIYDUKqbTYh1aKkRsIK5O19GvoJQ4UUzHV6o-raW8jTBdXRfH1Bz6N7CPfcPkivTn1a-zOthy1HrlFBCFCErJBum_3QhmAHkoA9UPOEKKZeJBl_k3VqsZBcNById-X591ukyi06Kk8kHfYoigiiXm7lv0-NLsHoVq9e4sBemIjYzHd3mUhN3ayPYOTAwnUCsb9kA' --header 'Content-Type: application/json' --data-raw '
{
"body": {
"content": "Hello world"
}
}'
Below will be the response
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#teams('<team-ID>')/channels('<channel_ID>')/messages/$entity",
"id": "1605635994172",
"replyToId": null,
"etag": "1605635994172",
"messageType": "message",
"createdDateTime": "2020-11-17T17:59:54.172Z",
"lastModifiedDateTime": "2020-11-17T17:59:54.172Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": null,
"importance": "normal",
"locale": "en-us",
"webUrl": "https://teams.microsoft.com/l/message/channel-ID/1605635994172?groupId=<team-ID>&tenantId=<tenant-ID>&createdTime=1605635994172&parentMessageId=1605635994172",
"policyViolation": null,
"from": {
"application": null,
"device": null,
"conversation": null,
"user": {
"id": "4faab178-9f24-4cd7-a144-d261c91d1ba2",
"displayName": "admin",
"userIdentityType": "aadUser"
}
},
"body": {
"contentType": "text",
"content": "Hello World"
},
"channelIdentity": {
"teamId": "team-ID",
"channelId": "channel-ID"
},
"attachments": [],
"mentions": [],
"reactions": []
}

Classroom Orphaned by deleted teacher account

My predecessor was in the habit of deleting users from gsuite. This has resulted in 18 courses that I cannot figure out how to change from ACTIVE to ARCHIVED.
GET https://classroom.googleapis.com/v1/courses/#######?key=[YOUR_API_KEY] HTTP/1.1
{
"id": "#######",
"name": "Course Name",
"ownerId": "#####################",
"creationTime": "2014-01-01T00:00:00.000Z",
"updateTime": "2015-01-01T00:00:00.000Z",
"enrollmentCode": "xx#xxx#",
"courseState": "ACTIVE",
"alternateLink": "https://classroom.google.com/c/XXX#XXXxXxxx",
"teacherGroupEmail": "Course_Name_teachers_#xXxXx#domain.com",
"courseGroupEmail": "Course_Name--#xXxXx#comain.com",
"teacherFolder": {
"id": "#X#Xx#xxX#xXXxXXXX#xXxXXxxXx"
},
"guardiansEnabled": false
}
Trying to PATCH the class to ARCHIVED:
curl --request PATCH \
'https://classroom.googleapis.com/v1/courses/#######?updateMask=courseState&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"courseState":"ARCHIVED"}' \
--compressed
Returns error 500:
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}
It's a bug that Google seems to be aware of and has no solution at this time.
https://issuetracker.google.com/issues/36760244#comment13

Does parse.com support batch operations for push notifications?

I am attempting to do a batch push notification request using the parse rest API.
curl -X POST
-H "X-Parse-Application-Id: redacted"
-H "X-Parse-REST-API-Key: redacted"
-H "Content-Type: application/json"
-d '{
"requests": [{
"method": "POST",
"path": "/1/push/",
"body": {
"channels": ["redacted"],
"deviceType": "ios",
"badge": 1,
"data": {
"alert": "Hello",
"badge": 1,
"key": "status"
}
}
}]
https://api.parse.com/1/batch
And am receiving the error:
{"code":107,"error":"Method 'POST' to '/1/push/' not supported in batch operations."}
You are already indicating POST in CURL. The Parse push api is not batch. Push is sent to registered devices in Parse (associated with a certificate from Apple) and those matching your push criteria. Your push message should look more like this:
curl -X POST \
-H "X-Parse-Application-Id: " \
-H "X-Parse-REST-API-Key: " \
-H "Content-Type: application/json" \
-d '{
"where": {
"channels": {
"$in": ["channel1","channel2","channel3"]
},
"deviceType": "ios"
},
"data": {
"alert": "Alert message here."
}
}' \
https://api.parse.com/1/push
There are various examples in the docs. The above is from the help forum.

Resources