Reputation: 63
According to that article https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx,
I am trying to fetch the list of events doing following:
$ curl -X GET -H "Content-Type:application/json" -H "Authorization:Bearer $TOKEN" "https://management.azure.com/subscriptions/SUBSCRIP-TI0N-xxxx-xxxx-xxxxxxxxxxxx/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01&\$filter=eventTimestamp ge '2014-12-29T22:00:37Z' and eventTimestamp le '2014-12-29T23:36:37Z' and eventChannels eq 'Admin, Operation'" -v
* Hostname was NOT found in DNS cache
* Trying 23.97.164.182...
* Connected to management.azure.com (23.97.164.182) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
* Server certificate: management.azure.com
* Server certificate: Microsoft IT SSL SHA2
* Server certificate: Baltimore CyberTrust Root
> GET /subscriptions/SUBSCRIP-TI0N-xxxx-xxxx-xxxxxxxxxxxx/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01&$filter=eventTimestamp ge '2014-12-29T22:00:37Z' and eventTimestamp le '2014-12-29T23:36:37Z' and eventChannels eq 'Admin, Operation' HTTP/1.1
> User-Agent: curl/7.37.1
> Host: management.azure.com
> Accept: */*
> Content-Type:application/json
> Authorization:Bearer {mytokenthere}
>
But the result is:
< HTTP/1.1 400 Bad Request
< Content-Type: text/html; charset=us-ascii
* Server Microsoft-HTTPAPI/2.0 is not blacklisted
< Server: Microsoft-HTTPAPI/2.0
< Date: Tue, 01 Dec 2015 10:06:38 GMT
< Connection: close
< Content-Length: 311
<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>
</BODY></HTML>
But it seems to be exactly the same request as in msdn example.
I believe it must be something wrong with filter param, when I amend it the response states that filter parameter is invalid:
curl -X GET -H "Content-Type:application/json" -H "Authorization:Bearer $TOKEN" "https://management.azure.com/subscriptions/SUBSCRIP-TI0N-xxxx-xxxx-xxxxxxxxxxxx/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01"
<Error xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/windowsazure"><Code>BadRequest</Code><Message>The $filter query parameter value is invalid.</Message></Error>
I also tried other filter options from the msdn article - the result is the same.
What am I doing wrong?
Upvotes: 1
Views: 2313
Reputation: 63
Oh, so it turns out that I incorrectly called curl and the problem is actually stupid :)
this is the way it works:
curl -H "Accept:application/json" -H "Authorization: Bearer $TOKEN" 'https://management.azure.com/subscriptions/{subscription_id}/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01&$filter=eventTimestamp%20ge%20%272015-11-29T22:00:37Z%27'
so %20 is used instead of spaces, and %27 instead of '
and it works!
Upvotes: 3
Reputation: 136369
I believe the problem is in the date range you're specifying. Please note that you can only query for last 90 days of data and you're querying the data for last year:
eventTimestamp ge '2014-12-29T22:00:37Z' and eventTimestamp le '2014-12-29T23:36:37Z'
Please try by changing the date/time range. Otherwise your query looks fine.
Upvotes: 0