Posting to API for Endpoint Groups Update

I am trying to move an endpoint from one group to another using the API. I have it all setup, I think, but when I do send the request I get an error from curl that it can't open the json I am sending. According to the API docs, this

curl --request POST \
'api-{dataRegion}.central.sophos.com/.../endpoints' \
--header 'Authorization: Bearer [YOUR_AUTH_INFO]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"ids":[]}' \
--compressed

Errors out on the ids string.

curl.exe : curl: Failed to open {"ids": ["xxxxxx-xxxx-xxxx-xxxx-xxxxxxx"]}

here is my interpretation in Powershell 

$Tenants = curl.exe -XPOST -H "Authorization: Bearer $jwt" "X-Tenant-ID: $Tenant_id" "$URL" "Accept: application/json" "Content-Type: application/json" -D $machines -compressed

Where $Machines looks like this: {\"ids\":  [\"xxxxxx-xxxx-xxxx-xxxx-xxxxxxx\"]}

Anybody else able to get a curl post to work? Any idea what is wrong with my example?

Do I need to convert to json while doing the curl call or before?



Updated the tags
[edited by: Gladys at 2:36 PM (GMT -8) on 1 Jan 2024]
Parents Reply
  • Hi Brian

    I was able to get this to work using Postman with the following code. While this looks similar, I suspect the group ID is not being included in the URL you're entering. Let me know if this helps.

    curl --location 'https://api-##DATA REGION##.central.sophos.com/endpoint/v1/endpoint-groups/##GROUP ID##>/endpoints' \
    --header 'X-Tenant-ID: ##TENANT ID##' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'Authorization: Bearer ##AUTH TOKEN##' \
    --data '{
      "ids": [
        "##DEVICE ID##"
      ]
    }'

    Kushal Lakhan
    Team Lead, Global Community Support
    Connect with Sophos Support, get alerted, and be informed.
    If a post solves your question, please use the "Verify Answer" button.
    The New Home of Sophos Support Videos!  Visit Sophos Techvids
Children