I am trying to run shell script with a curl command as below with --data-raw as body.
curl --location --request POST '<URL>' \
--header 'Content-Type: application/json' \
--data-raw '{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Help Text",
"emoji": true
}
},
{
"type": "divider"
},
]
}'
Output:
curl: option --data-raw: is unknown
curl: try 'curl --help' or 'curl --manual' for more information
I couldn't find any error with the json validator. Please suggest a solution. TIA.
Here, you have 2 issue.
your JSON is invalid, the , line 14 need to be removed
use --data and a heredoc :
curl --location --request POST '<URL>' \
--header 'Content-Type: application/json' \
--data "#/dev/stdin"<<EOF
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Help Text",
"emoji": true
}
},
{
"type": "divider"
}
]
}
EOF
Here documents:
cat <<EOF followed by several lines of text, followed by the literal string EOF on a new line, NOT indented. The portion between the EOFs is passed to the command as standard input. If 'EOF' is 'quoted', substitutions WON'T be done; otherwise they are. See <<- for the indented variety (not recommended, need TABs).
Related
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.
I've been working on creating a script utilizes curl and variables. Doing some searches I found how to place a variable in the data portion of the curl but now I'm getting errors from the curl command.
(Some parts of the code removed to keep passwords out, everything is working except for entering the data into the --data portion of curl)
curlData=$(cat <<EOF
{
"rebootClient": false,
"createPseudoClientRequest": {
"registerClient": true,
"clientInfo": {
"clientType": 0,
}
},
"packages": [
{
"packageId": 702,
"packageName": "File System",
"packageId": 51,
"packageName": "MediaAgent"
}
],
},
"entities": [
{
"clientId": 0,
}
]
}
EOF
)
shopt -u nocasematch #Sets options back to being case sensitive
echo "$csName"
curl -vv --location --request POST "http://$csName:81/SearchSvc/CVWebService.svc/InstallClient" --header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header "Authtoken: $token" \
-d "$curlData"
Doing a bash -x everything looks correct
"rebootClient": false,
"createPseudoClientRequest": {
"registerClient": true,
"clientInfo": {
"clientType": 0,
}
},
"packages": [
{
"packageId": 702,
"packageName": "File System",
"packageId": 51,
"packageName": "MediaAgent"
}
],
"clientAuthForJob": {
},
"entities": [
{
"clientId": 0,
"clientName": "srybrcost",
}
]
}'
But every time I get Request body is empty or format is invalid
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
I try to perform an update with ajax on my db but it's not working.
Url i tried :
http://localhost:8880/api/Tracks/update?filter{"id ": "1"}
What i get :
{
"error": {
"name": "AssertionError",
"status": 500,
"message": "The where argument must be an object",
"actual": false,
"expected": true,
"operator": "==",
"generatedMessage": false,
}
}
Thanks !
Try for this:
curl -X PUT --header "Content-Type: application/json" --header "Accept: application/json" -d "{
//your data here
}" "http://localhost:aaaa/xx/yy/%7B%22id%22%3A1%7D"
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.