I'm sending a Postman request to get the metrics from an event grid like this:
https://management.azure.com/subscriptions/{suscription id}/resourceGroups/{name of resource group}/providers/microsoft.insights/metricDefinitions/?api-version=2018-01-01
I'm also attaching the Bearer token.
However, I keep getting the following response:
{
"message": "An error has occurred.",
"exceptionMessage": "ApiVersion: 2018-01-01 does not support query at non Arm resource Id level",
"exceptionType": "Microsoft.Online.Metrics.MetricsMP.Utilities.RPRequestFormatException",
"stackTrace": " at Microsoft.Online.Metrics.MetricsMP.Controllers.MPController_MetricDefinitions_Base.<MetricDefinitionAtResourceGroup>d__4.MoveNext() in ...
....
}
What does that mean and how can I fix it? I've been looking on the Internet and there's not much information.
Your URL is wrong.As far as I know,if you want to retrieve metric definitions, the rest api is that
Method: GET
Request URI:
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/microsoft.insights/metricDefinitions?api-version={apiVersion}
For more details, please refer to
https://learn.microsoft.com/en-us/rest/api/monitor/metricdefinitions/metricdefinitions_list
https://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-rest-api-walkthrough.
To get the metric definitions use this rest API
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource
ProviderNamespace}/{resource
Type}/{resourceName}/providers/microsoft.insights/metricdefinitions?api-version=2018-01-01
To get the metrics with optional parameters use this rest API
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/metrics?timespan={timeSpan}&interval={timeGranularity}&aggregation={AggregationType}&metricnames={metricName}&api-version=2018-01-01
You missed the resource type and name in the request url, the url should be like below:
https://management.azure.com/{resourceUri}/providers/microsoft.insights/metricDefinitions
Reference: https://learn.microsoft.com/en-us/rest/api/monitor/metricdefinitions/list
If you want to list metric definitions of an event grid, your url should be:
GET https://management.azure.com/subscriptions/{subscription id}/resourceGroups/{resource group name}/providers/Microsoft.EventGrid/topics/{event grid topic name}/providers/microsoft.insights/metricDefinitions?api-version=2018-01-01
Test result:
Related
I'm trying to fetch data from REST API and save the json string it into DataLake and I'm getting an error. I've followed the steps mentioned here
https://learn.microsoft.com/en-us/azure/data-factory/connector-rest & https://www.alexvolok.com/2019/adfv2-rest-api-part1-oauth2/
The API which I'm trying to connect uses OAuth2 so I need to first get the access token and then do a get request to get actual data.
Below are the steps which I'm following
Creating a Web HTTP request in the pipeline and passing the client_ID, client secret, username, password and grant type in the body of the request. When I debug the pipline I do get the Access_token which I need in step 2.
In Step two I have a copy activity which uses the output(access_token) from web to authenticate the second REST GET request but this is where I'm facing a lot of issues. The code which I'm using is "#concat('Bearer ', activity('GetAccessToken').output.access_token)"
In step 3 I have two datasets and 2 Linked services, Dataset 1 is a REST dataset which has the base url and relative url which is linked to the REST linked service and secondly the sink dataset is connected to AZURE datalake storage.
In Source Dataset I'm passing additional header Authorization = #concat('Bearer ', activity('GetAccessToken').output.access_token) and ideally since the API which I want to call will return empty if no parameters are send so I pass in the parameters inside the "Request Body" is that even correct? the Request body would look something like this "start_date=2020/07/17&end_date=2020/07/18".
The sink is a simple Json dataset stored in DataLake.
When I try to debug I get the error as below
But I'm getting the below error
{
"errorCode": "2200",
"message": "Failure happened on 'Source' side. ErrorCode=UserErrorHttpStatusCodeIndicatingFailure,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=The HttpStatusCode 401 indicates failure. { \"Error\": { \"Message\":\"Authentication failed: Invalid headers\", \"Server-Time\":\"2020-07-27T06:59:24\", \"Id\":\"6AAF87BC-5634-4C28-8626-810A19B86BFF\" } },Source=Microsoft.DataTransfer.ClientLibrary,'",
"failureType": "UserError",
"target": "CopyDataFromAPI",
"details": []
}
Please advise if I'm doing anything wrong.
I Knew this was a simple issue,
So for people who are looking for answers.
Please make sure the REST Source URL starts with HTTPS:// instead of HTTP:// I Guess Azure does not pass headers to url which starts with HTTP:// which is strange because POSTMAN and python script has no problem sending the headers.
I am utilizing the Custom Translation API with POST endpoint: https://api.cognitive.microsofttranslator.com/translate
The full query url with Category ID obfuscated is: https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&category=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-GENERAL&from=en&to=fr&includeSentenceLength=true
This query works without the category parameter but fails with the following response when it is included:
{
"error": {
"code": 400002,
"message": "The category parameter is invalid."
}
}
I have added the Subscription Key into the Custom Translation Portal. Not sure why this request fails.
Turns out I'm an idiot. Even with a simple Dictionary as I had in this case, one must still train and deploy a model with that dictionary.
Based on the documentation contained in the original code I try to access API Management and filter for a certain product:
credentials = ServicePrincipalCredentials(
client_id=clientId,
secret=secret,
tenant=tenantId)
client = ApiManagementClient(credentials, subscription_id)
products = client.product.list_by_service(resource_group_name,service_name,filter="displayName eq 'INTERNAL'")
which seems valid and according to documentation to me.
However I get this error:
azure.mgmt.apimanagement.models.error_response_py3.ErrorResponseException: Invalid filter clause specified: 'DisplayName eq 'INTERNAL''.
I tried to inspect the source codes of Azure API Management Python SDK which include product_operations.py, [error_response_py3.py][1], msrest-for-python/msrest/serialization.py, there is not any obvious issue.
Then, after I tried to test the relative REST API Product - List By Service of ApiManagement.product.list_by_service function, I discovered the issue may be a bug.
There are six fields can be used in the $filter URI parameter: name, displayName, description, terms, state and groups. Except groups which I don't know how to feed the corrent expression for $filter, I test the rest five fields and only displayName does not work.
The api-version value is 2019-01-01, the json response for %24filter=displayName%20eq%20%27Starter%27 in my uri parameter is as below.
{
"error": {
"code": "ValidationError",
"message": "Invalid filter clause specified: 'displayName eq 'Starter''.",
"details": null
}
}
So I think it's not your mistake while using Azure API Management Python SDK, it's a bug which seems to be not implemented or other reason.
I am new in web development and trying to learn AWS.
I have made a lambda function for listing.
What I am doing here is I am showing listing, if I get counteId in params(URL) then it shows only data of that counter id else it shows all data.
My lambda function was working fine. But I am having a problem while API integration.
this is how I am accessing pathparameters which are in the event
this is how I am configuring event
and this is my query and response
then I create an API gateway for it.
this is what I did while creating Resource
/{proxy+} - ANY - Setup
I want to get only data of counterId 1, but I am getting whole data.
response
My HTTPmethod is "ANY" and I choose lambda proxy integration in request integration.
I don't know how to send path parameters. Kindly help me.
You have to edit 'Mapping Template' in 'Integration Request' of you method properties in API Gateway.
You could find how to map it in API Gateway Mapping Template Reference article, in the 'Accessing the $input Variable' section.
Your template has to look like next:
{
"name" : "$input.params('name')",
"body" : $input.json('$')
}
Check out more details in my answer to the similar question.
I'm trying to set up the Bing Spell Check API on my Microsoft Azure account. The deployment, however, fails with the following error message:
OPERATION ID 492286237BA7FFEB
TRACKING ID 779d79cf-4b12-487f-ba97-c896bbdccb87
STATUS Conflict
PROVISIONING STATE Failed
TIMESTAMP 24/2/2017 09.55.58
DURATION 1 minute 22 seconds
TYPE Microsoft.CognitiveServices/accounts
RESOURCE ID /subscriptions/c68eec07-13e6-4f40-831c-c42f996fca89/resourceGroups/webis2/providers/Microsoft.CognitiveServices/accounts/webis
STATUSMESSAGE {
"error": {
"code": "RequestConflict",
"message": "Cannot replace resource with id 'webis'
because the resource entity tag has changed
while processing this request.
Please retry the request with the updated
resource."
}
}
RESOURCE webis
The STATUSMESSAGE suggests to simply retry the request, but this fails, too, with the same error message.
Otherwise, I'm not sure how to resolve the issue, since I obviously have no access to the provisioning process of the Bing Spell Check API.
Any help would be greatly appreciated.
We are investigating this. For now you should be able to work around the issue by deploying to an existing Resource Group instead of creating a new Resource Group during the API account creation.
Update: This issue has been resolved and new API account creation should work correctly.