azure -command not found while running GET command - azure

curl -X GET -H "Authorization: Bearer<token>" -H "Content-Type: application/json" https://management.azure.com/subscriptions/xxxx-xxx-xxxxxx-xxxxxxxxx/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter=eventTimestamp ge '2019-03-21T00:00:00Z' and eventTimestamp le '2019-03-24T20:40:00Z' and resourceGroupName eq 'name'&$select=operationName,status,level
This command is used for collection azure activity log I am running this command in the CLI its giving error
bash: =,status,level: command not found...
bash: =eventTimestamp: command not found...

Hi I found the solution myself
the POST request that you are using copy and paste to Postman(software). Then click on "code". https://management.azure.com/subscriptions/xxxx-xxxxx-xxxxx-xxx/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter=eventTimestamp%20ge%20%272019-03-21T00:00:00Z%27%20and%20eventTimestamp%20le%20%272019-03-24T20:40:00Z%27%20and%20resourceGroupName%20eq%20%27Ajay%27&$select=operationName,status,level'

Related

windows command prompt curl POST to run Azure DevOps pipeline

I am trying to run an Azure DevOps pipeline from the windows command prompt using curl.
Based on Microsoft documentation ( Runs - Run Pipeline ) I should be able to run a pipeline by posting:
https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=6.0-preview.1
I am able to GET using the command:
curl -u :<PAT> https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=6.0-preview.1
However, I can't figure out how to do a POST for DevOps using curl to run the pipeline.
I have tried the following:
curl -s -X POST -L https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=6.0-preview.1 -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Basic <PAT>"
But this returns the error
HTTP Error 411. The request must be chunked or have a content length
I managed to solve my problem which consisted of numerous steps:
Log the API call from the DevOps website to get the correct format of the json-body ( See this question ).
Format the json-body with extra double quotation signs.
Use the {project}-id instead of the ascii-name since it included a special character which the command prompt misinterpret.
Hence the complete curl command was:
curl -X POST -u :<PAT> "https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=6.0-preview.1" -H "Content-Type: application/json" -d "{""stagesToSkip"": ""[]"", ""resources"": {""repositories"": {""self"": {""refName"": ""refs/heads/master""}}}}"

Run query API in curl

I'm trying to explore the curl connect or retrieve the data with query API link but when I run my GET command in curl it runs without any error shown in -vv but the process stop. below the actual statement at the end of the posted process, may I know if this is normal or I need to add an additional arguments or parameters on my command for me to retrieve the data? If yes may I know how to do it?
Connection #1 to host myserver.com left intact
My command
curl -vv -k -X GET -H --user user123:password1 -H "Accept: application/json" https://myapplink/statement/EXE=sample

Store output of command in variable where the command is already executed/stored in it's own variable - bash script

I have a command that is stored in a variable. I would like to execute that command and then store the response of that command in a variable. I'm having an issue with syntax errors for the responseVar=$("{commandVar}") line as it seems to trigger a "no such file or directory" error instead of actually running the command/storing the output in the response variable.
commandVar="curl --location -g --request POST 'https://172.217.25.35/rest-gateway/rest/api/v1/auth/token' --header 'Content-Type: application/json' --header 'Authorization: Basic U0FNcWE6NTYyMFNhbSE=' --data-raw '{"grant_type": "client_credentials"}'"
responseVar=$("{commandVar}")
echo "Response of command: ${responseVar}"
Does anyone know the correct syntax on how I would do this? I need to eventually parse the output of the command which is why I need to store the response in it's own variable.
You are trying to execute a program named {commandVar}, and this program does not exist in your PATH.
To start with, you better use an array to store your command, each array element holding one command argument:
commandVar=(curl --location -g --request POST 'https://172.217.25.35/rest-gateway/rest/api/v1/auth/token' --header 'Content-Type: application/json' --header 'Authorization: Basic U0FNcWE6NTYyMFNhbSE=' --data-raw '{"grant_type": "client_credentials"}')
With this, you can execute it by
"${commandVar[#]}"
respectively store its standardoutput into a variable like this:
responseVar=$( "${commandVar[#]}" )

Rasa nlu server failure

I started the rasa server by typing this command in cmd:
rasa run --enable-api -m models/(my_model).tar.gz --cors "*" --debug
I put this command in another cmd:
curl -X POST localhost:5005/model/parse -d '{"text":"hello"}'
After that I got this error:
{"version":"1.2.2","status":"failure","message":"An unexpected error occurred. Error: Failed when parsing body as json","reason":"ParsingError","details":{},"help":null,"code":500}
Any help? How can I integrate Rasa with Node.js?
Please try
curl -H "Content-Type: application/json" -X POST -d '{"sender":"y1mLd","message":"hi"}' http://localhost:5005/webhooks/rest/webhook
Output would be
[{"recipient_id":"y1mLd","text":"Welcome, Please let me know how I could be a help today!"}]
Hope this helps!
Simple curl without method type worked for me:
curl localhost:5005/model/parse -d '{"text":"hello"}'
I also faced this error on Windows 10 . Following commands worked for me finally.
curl localhost:5005/model/parse -d "{\"text\":\"hello\"}"
and
curl -H "Content-Type: application/json" -X POST localhost:5005/model/parse -d "{\"text\":\"hello\"}"

curl command in linux

How we can add JSON parameters in a curl command to fetch data ?
PS: I have tried to fetch data from some source using curl command but it requires passing JSON parameters in it. So how I will accomplish it ?
I think mentioning content type as json and passing data will do the things right
curl -H "Content-Type: application/json" -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here
Above will work for GET Method, for POST method
curl -H "Content-Type: application/json" -X POST -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here

Resources