Azure Media Service REST API error MissingApiVersionParameter - azure

I am trying setup media service pipeline via rest services using
https://learn.microsoft.com/en-us/azure/media-services/latest/stream-files-tutorial-with-rest
Section : Encode remote file stream video – REST
We are getting an error at mentioned Step : Create an output asset
As per documentation
https://management.azure.com/subscriptions/:subscriptionId/resourceGroups/:resourceGroupName/providers/Microsoft.Media/mediaServices/:accountName/assets/:assetName?api-version={{api-version}}
Endpoint that we generaetd: https://management.azure.com/subscriptions/xxxx-xxx-xxx-xxx-xxxxxxxxxx/resourceGroups/xxxxxx_resource_group/providers/Microsoft.Media/mediaServices/xxxxx/assets/xxxxxxxxxx?api-version=2018-08-01
Even if we give api version as 2.1, 2.2 etc …. Then also error is same.
response error :
{
"error": {
"code": "MissingApiVersionParameter",
"message": "The api-version query parameter (?api-version=) is required for all requests."
}
}

In REST v2 the API versions were 2.0 through 2.19, current. But in the REST v3 the API the released version is 2018-07-01. See
https://learn.microsoft.com/en-us/rest/api/media/assets/createorupdate.

Also, download the Postman Collection for V3 and look at the URLs. Make sure that you are formatting them properly.
https://learn.microsoft.com/en-us/azure/media-services/latest/media-rest-apis-with-postman
Use the Postman Console to see the full URL post (open via Alt-CTL-C)
Typical create Asset call would look like:
https://management.azure.com/subscriptions/:subscriptionId/resourceGroups/:resourceGroupName/providers/Microsoft.Media/mediaServices/:accountName/assets/:assetName?api-version={{api-version}}
"/assets?api-version=2018-07-01" is an example

Related

How to get file comments using Sharepoint rest api

I'm using the following api to successfully get file data:
https://acme.sharepoint.com/sites/my-site/_api/Web/Lists(guid'xxx')/files('yyy')
This is a docx file on which I've posted comments using the web console.
How can I fetch these comments using the rest api? I tried appending /comments to the url, but I'm getting the following 404 error:
{
"error": {
"code": "-1, Microsoft.SharePoint.Client.ResourceNotFoundException",
"message": {
"lang": "en-US",
"value": "Cannot find resource for the request Comments."
}
}
}
The Comments() endpoint currently exists only under the Items() endpoint and not under the Files() endpoint.
Basically, you can access the Comments() functionality only under the below endpoint:
GET https://{site_url}/_api/web/lists/GetByTitle({list_title})/items({item_id})/Comments
You can easily test the above in a PowerAutomate scenario with a Send Http Request to SharePoint actions.
In the below example I attempt to target the file in the document library:
On the other hand, if I attempt to target the file based on the List Item Id that it got in the document library I will get the below response:
As you can see from the above, I am also able to target a specific comment that I left.
Please take note of the below
The Comments() endpoint is not available for MS resources, meaning docx, excels and such files. It is only available for non-MS resource files like pdfs, txts and so on. I am not sure why this rule is in effect but, my best guess would be because there is a "commenting" functionality provided within a Word Document, for example.
You could find a bit more info about the above here.

presetOverride when creating Azure Media Services v3 Job

When creating an Azure Media Services Job via the REST API, I cannot set a presetOverrides property on the JobOutputAsset as defined in the documentation: https://learn.microsoft.com/en-us/rest/api/media/jobs/create#joboutputasset
My request body is:
{
"properties": {
"input": {
"#odata.type": "#Microsoft.Media.JobInputAsset",
"assetName": "inputAsset"
},
"outputs": [
{
"#odata.type": "#Microsoft.Media.JobOutputAsset",
"assetName": "outputAsset",
"label": "en-US",
"presetOverride": {
"#odata.type": "#Microsoft.Media.AudioAnalyzerPreset",
"audioLanguage": "en-US",
"mode": "Basic"
}
}
],
"priority" : "Normal"
}
}
The error message thrown is:
{
"error": {
"code": "InvalidResource",
"message": "The property 'presetOverride' does not exist on type 'Microsoft.Media.JobOutputAsset'. Make sure to only use property names that are defined by the type."
}
}
When removing the presetOverride data, everything works as expected. The official documentation clearly states that the Microsoft.Media.JobOutputAsset does have a presetOverride property though. What am I doing wrong?
It is important to select the correct API version when communicating with the Azure Media Services REST API.
In this case, api version 2020-05-01 from the Azure Media Services Postman examples was used. But the presetOverride option is only available starting with version 2021-06-01.
Setting api-version=2021-06-01 as a GET parameter enables Preset Overrides.
couple of concerns here Rene. I would not recommend using the raw REST API directly for any Azure services. Reason being is that there are a lot of built-in retry scenarios and retry policies that are already rolled into the client SDKs. We've had many customers try to roll their own REST API library but run into massive issues in production because they failed to read up on how to handle and write their own custom retry policy code.
Unless you are really familiar with rolling your own retry policies and how Azure Resource Management gateway works, try to avoid it and just use the official client SDKs - see here - https://learn.microsoft.com/en-us/azure/architecture/best-practices/retry-service-specific#general-rest-and-retry-guidelines
Now, to answer your specific question - try using my sample here in .NET and see if it answers your question.
https://github.com/Azure-Samples/media-services-v3-dotnet/blob/3ab85647cbadd2b868aadf175afdede67b40b2fd/AudioAnalytics/AudioAnalyzer/Program.cs#L129
I can also provide a working sample of this in Node.js/Typescript in this repo if you like. It is using the latest 10.0.0 release of our Javascript SDK.
I'm working on samples in this repo today - https://github.com/Azure-Samples/media-services-v3-node-tutorials
UPDATE: Added basic audio in Typescript sample.
https://github.com/Azure-Samples/media-services-v3-node-tutorials/blob/main/AudioAnalytics/index.ts
Shows how to use the preset override per job.

application not found with luis api version 3.0 preview

I was testing the new preview 3.0 version for LUIS on the test console available at "https://westus.dev.cognitive.microsoft.com/docs/services/luis-endpoint-api-v3-0-preview/operations/5cb0a9459a1fe8fa44c28dd8/console" .
Despite I am using the same key and app id that correctly work for version 2.0 I get as response the error message "The application wasn't found. Please make sure that the application is published to this region".
The ID for the application I inserted in the console form is published for westus region, the error message seems not truthful.
Anybody else is having the same issue?
Thanks
It seems like a bug in the documentation. Please try adding /slot/{slotName}/ before the predict keyword, where slotName is either staging or production. So the url becomes:
https://westus.api.cognitive.microsoft.com/luis/v3.0-preview/apps/{appId}/versions/{versionId}/slots/{slotName}/predict?query={query}
An example would be:
https://westus.api.cognitive.microsoft.com/luis/v3.0-preview/apps/a1fc3658-a4c5-4fb2-88d3-69ba49e7abad/versions/0.1/slots/production/predict?query={query}
Thanks for your reply.
I added the /slot/production or /slot/staging part to the URL but this seems not to be enough for me.
After this change I get a 404 error as answer:
{
"error": {
"statusCode": 404,
"message": "Resource not found"
}
}
This is a new feature introduced in v3. We now allow publishing to the endpoint using the version Id instead of publishing to a slot. Since the version publishing isn't supported in the UI currently, you won't be able to publish to a version (yet). For now, use the publishing slot as Omar suggests.
Below the working Request URL produced by the get published slot prediction console, available at https://westus.dev.cognitive.microsoft.com/docs/services/luis-endpoint-api-v3-0-preview/operations/5cb0a91e54c9db63d589f433/console :
https://westus.api.cognitive.microsoft.com/luis/v3.0-preview/apps/{APPID}/slots/Production/predict?query={QUERY}&verbose=true&log=true&show-all-intents=true
Thanks

Instagram users/self/feed 404 errorcode

I am trying to get myself mediafeeds information with the following API (using JInstagram library):
https://api.instagram.com/v1/users/self/feed?access_token={valid access_token}
The response code is 404. I am not sure what I'm missing since the access_token is valid, the API is listed in the Ruby library, but it can't be found on the develop website.
I see there is a 404 error in this site for feeds to, but it are not same API.
Instagram changed their policy and also deprecated some APIs. Check the below link.
https://instagram.com/developer/changelog/
Old API
https://api.instagram.com/v1/users/self/feed?access_token={valid access_token}
Use the below API instead of the above one
https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN

Cannot upload github release asset through API

I have a github release with no assets yet:
$ curl https://api.github.com/repos/cljsinfo/api-docs/releases/1260660/assets
[
]
But I cannot upload an asset to this release:
$ curl -X POST --header "Content-Type:application/edn" --data-binary #cljsdocs-full.edn "https://api.github.com/repos/cljsinfo/api-docs/releases/1260660/assets?name=full.edn&access_token=$(cat my-token)"
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
}
my api access token has public_repo access. Thanks for any helping on uploading this asset.
You're making the POST request to https://api.github.com/repos/cljsinfo/api-docs/releases/1260660/assets which is not the upload URL for the release. It should be https://uploads.github.com/repos/cljsinfo/api-docs/releases/1260660/assets.
See the docs for more info:
https://developer.github.com/v3/repos/releases/#upload-a-release-asset
The asset upload URL is of the form https://<upload_url>/repos/:owner/:repo/releases/:id/assets?name=foo.zip. There are several possible reasons you might get the very unhelpful "Not Found" error:
Wrong release id. The :id field in the URL above is NOT the name you gave the release, but a numeric id generated by GitHub (probably a database ID). To get the release ID, you have to call the releases API and search through the JSON response for a release where the tag_name is equal to the name you used. For example, if you named your release v0.0.3, search in the JSON for a release with "tag_name": "v0.0.3" and use that release's id field.
Wrong upload URL. The URL you use to upload assets is not the same one ou use for all other API calls. To get the right upload URL, you use the same releases API, find your release using tag_name a described above, and extract the upload_url field from the JSON response. This is Ivan's (accepted) answer.
Missing GitHub access token permissions. This is the one that tripped me up the worst, as the token I was using was able to make API calls to the releases API and get info about my repo, but NOT upload assets to that same repo. The "Not Found" error response doesn't hint at this at all. Check the permissions for your token in your personal access tokens page and make sure repo and/or public_repo are checked, as appropriate.
Note that for Enterprise flavored GitHub, the upload url isn't the same form as for 'github.com', and you should use the 'upload_url' returned when creating/querying the release:Get Release API Docs
For example here's what's returned from our enterprise github server (slightly munged to protect the guilty):"upload_url": "https://git.example.com/api/uploads/repos/example-owner/example-repo/releases/5/assets{?name,label}",

Resources