05 Mar 2019 02:29 PM - last edited on 13 Dec 2021 11:25 AM by MaciejNeumann
the example does not show how to use a json file as input to the curl command. the -d format is shown. I am doing a "POST/autoTagsCreates a new auto tag" I am using bash
My command that does not work
curl -k -X POST "https://${TooTenant}/api/config/v1/autoTags?Api-Token=${TooToken}" -H "accept: application/json; charset=utf-8" -H "accept: application/json; charset=utf-8" -H "Content-Type: application/json; charset=utf-8" -d /export/apm/eds-Prod-oneagent/tmp/Tmp.json
Thanks for your help in advance
Ed
Solved! Go to Solution.
05 Mar 2019 02:51 PM
Better use the PUT method to create or update a configuration. The POST method does not allow to provide your own configuration record id, while the PUT does.
08 Mar 2019 03:58 PM
sorry I need to use the Json as input to post config eg -d /export/apm/eds-Prod-oneagent/tmp/Tmp.json
When coping to environment I don't want the ID do I? It creates a new ID for me. It also could be on another cluster. I remove the ID before post.
11 Mar 2019 06:08 AM
PUT means create or update. So you can use curl -k -X PUT "...." -d /export...
Its nothing wrong in using the same GUID for the same config object across environments.
11 Mar 2019 12:39 PM
ok environment to environment but what about cluster to cluster?
my question is can I use the -d to point to a file eg
curl -X PUT "https://dynatrace-le.fanniemae.com/e/b35a1f50-6843-451e-9512-640d11de3507/api/config/v1/autoTags/de6056da-91fe-4333-a764-3af89f5a377f?Api-Token=3LtUywPpTNqmHYJCjSkQb" -H "accept: application/json; charset=utf-8" -H "Content-Type: application/json; charset=utf-8" -d "{ \"id\": \"de6056da-91fe-4333-a764-3af89f5a377f\", \"name\": \"1edtest\", \"rules\": [ { \"type\": \"SERVICE\",...
verses
curl -X PUT "https://dynatrace-le.fanniemae.com/e/b35a1f50-6843-451e-9512-640d11de3507/api/config/v1/autoTags/de6056da-91fe-4333-a764-3af89f5a377f?Api-Token=3LtUywPpTNqmHYJCjSkQb" -H "accept: application/json; charset=utf-8" -H "Content-Type: application/json; charset=utf-8" -d /export/apm/json.file in the format:
{"name":"sampleAutoTag","rules":[{"type":"SERVICE","enabled":true,"valueFormat":"myTagValue {Service:DetectedName}","propagationTypes":["SERVICE_TO_HOST_LIKE"],"conditions":[{"key":{....
I get
{"error":{"code":400,"message":"Syntax error near line 1 column 2"}}plsys-apapm01 apm/eds-Prod-oneagent%
I have -d "/export/apm/eds-Prod-oneagent/tmp/EdTmp.json"
11 Mar 2019 01:01 PM
Hi,
You can use -d with an @ to point at a filename.
curl -X PUT "https://dynatrace-le.fanniemae.com/e/b35a1f50-6843-451e-9512-640d11de3507/api/config/v1/autoTags/de6...***" -H "accept: application/json; charset=utf-8" -H "Content-Type: application/json; charset=utf-8" -d "@/export/apm/json.file"