cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configuration API's and curl

edward_prinsloo
Participant

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

 

5 REPLIES 5

wolfgang_beer
Dynatrace Leader
Dynatrace Leader

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.


edward_prinsloo
Participant

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.


wolfgang_beer
Dynatrace Leader
Dynatrace Leader

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.


edward_prinsloo
Participant

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"

eduard_van_der1
Dynatrace Helper
Dynatrace Helper

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"


Featured Posts