Luis: Access denied due to invalid subscription key - azure-language-understanding

I am facing following issue when i try to update application on Luis using following request:
https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/app-id-here
header:
Ocp-Apim-Subscription-Key:paid-subscription key
body:
{
"name": "Name of luis app",
"description": "string"
}
I am getting following error:
{
"statusCode": 401,
"message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription."
}
I am using paid subscription from Azure portal with westus region. Still facing this issue.
However, This key works when I try to get top scoring intent using following request:
https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/luis-app-id?subscription-key=subscription-key-azure&timezoneOffset=-360&q=hi
This is really weird as sunscription key works for GET request but not for PUT or POST request.
Any suggestions?
PS: I am using paid subscription key.

The (subscription) keys created with a Cognitive Service LUIS resource in Azure Portal, even when added to with Assign resource in luis.ai, can only be used for runtime queries on a defined app.
The authoring endpoints on LUIS Programmatic APIs v2.0 - to create and manage apps and their elements - can only be used with the Authoring Key available in the luis.ai portal.
More information can be found in Authoring and query prediction endpoint keys in LUIS

It looks like you have two issues you are working thru here.
First, the API you are trying to post to should read "https://[location].api.cognitive.microsoft.com/luis/api/v2.0/apps/{appId}/publish". From the looks of it, you are missing the 'publish' at the end of your API call.
Second, the paid subscription key needs to be added to your LUIS app. Can you confirm it has been added? If not, follow these steps to do so:
Click Manage => Keys and Endpoints.
Next, click 'Assign resource'.
A window will pop up allowing you to select the tenant, subscription, and the key to use.
Click OK.
Click 'Publish' to make the newly generated endpoint accessible.

Make sure you add subscription primary key value in my request and also make sure you have associated your API with the product which you used the Primary key

Related

Unable to assign LUIS az accounts to LUIS apps via REST

The luis resources that I created aren't showing up in the Luis portal (posted a question here) so decided to use the REST APIs to configure things manually. With the REST endpoints I was able to import apps. However, I wasn't able to add LU resource to the imported apps despite that the APIs return success.
Below is the call.
POST https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/<appid>/azureaccounts
{
"azureSubscriptionId": "<id>",
"resourceGroup": "<rg name>",
"accountName": "<resource name>"
}
returns 201 CREATED
{
"code": "Success",
"message": "Operation Successful"
}
However, a subsequent GET call returns empty result.
GET https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/<appid>/azureaccounts
tried the GET call a couple hours after and it is still returning empty result. What is going on?
It sounds like there's something wrong with your azure account and/or your luis.ai account. There are two places to raise support requests to handle these types of matters. First is uservoice on LUIS.ai:
While issues raised here are typically routed back to the bot framework support team, once there, they can be escalated.
Secondly, you can raise the issue in Azure:
You can follow this link HERE to get to that blade quickly.

How to update Virtual Assistant bot when LUIS endpoint changes

I am trying to switch from using the LUIS Authoring Key to using a Subscription Key for both my Assistant and my Skill. I created a Subscription Key and assigned it to the LUIS app. What do I need to modify in a Virtual Assistant bot to get it to use the new the new key/endpoint?
I changed the prediction endpoint key to use a Subscription Key so I don't hit HTTP 403 and HTTP 429 errors and now I need to understand what I need to change in both the Assistant and Skill projects to use this new endpoint.
You can update the cognitivemodels.json file to use the subscription key assigned. You need to modify the cognitivemodels.json file in both the Virtual Assistant and Skill (or each skill). Then just re-publish your bot.

Azure Bot-Builder : dispatch refresh fails with 401 error

We provisioned bot services using "msbot clone services ..." command. As part of this command a *.dispatch file is created with all the correct details.
The dispatch aggregates QnAMaker knowledge base and a LUIS app. We have verified the .dispatch file and also the .bot file to ensure correct keys are being used. The only change if any is we are not using starter_key in LUIS, rather we have generated a new key and this new key reflects in .dispatch and .bot file (when decrypted).
We have encrypted the .bot file correctly and tried following commands, and both fail with same error:
dispatch refresh --bot mybot.bot --secret
dispatch refresh --dispatch dispatch-file.dispatch
Error
Exporting LUIS application...
ERROR
One or more errors occurred. (The remote server returned an error: (401) Access Denied.)
Request url: https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/<LUIS-APP-ID>/versions/0.1/export
Response: { "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }
There are two different keys being used to use Dispatch CLI tool. Authoring key and subscription key. Authoring key is the key from luis.ai portal and needed to export the LUIS sources for Dispatch and to upload the newly created Dispatch app to luis portal. Subscription key is optional and is used for hitting luis endpoint/prediction API. If subscription key (created from Azure portal for LUIS Cognitive Service) is put in place of authoring key, Dispatch CLI won't be able to create and upload/refresh Dispatch app into luis. This is the expected behavior at the moment.
Having the exact same issue. With the starter key everything worked fine.
Edit: seems like an issue with Microsoft API.
You can use the starter key to update the dispatch model even though the query limit is reached.
My workaround was:
replace the subscriptionkey with the original starter key (authoringkey in luis)
run dispatch refresh
switch the keys again to allow for queries

Dynamics CRM Web API - Assign Records / Update Owner field

I am trying to create a Task record in Dynamics 365 and I want the owner to be a team record for which I have already retrieved the GUID.
This is my JSON and it always fails.
{
"ownerid_team#odata.bind":"/teams(f7e383eb-3966-e711-8122-e0071b66c021)",
"scheduledend":"2017-07-20",
"regardingobjectid_new_survey#odata.bind":"new_surveies(f7e383eb-3966-e711-8122-e0071b84b034)",
"subject":"Amazon SES has suppressed sending to this address because it has a recent history of bouncing as an invalid address.",
}
I get a bad request.
Can we not use the Web API to update the owner field of records? I could not find any specific limitations describing the same.
Maybe try:
"ownerid#odata.bind":"/teams(f7e383eb-3966-e711-8122-e0071b66c021)",
Using Jason Lattimer's CRM REST Builder, I've gotten this to work:
entity["ownerid#odata.bind"] = "/teams(956B410F-0F6E-E711-810E-00155D6FD705)";
One thing to ensure is that the team has a valid security role. You might want to try assigning the team in the UI to make sure the operation works before trying to do it programmatically.

Google Classroom API modifyAttachments

When executing the courses.courseWork.studentSubmissions.modifyAttachments method in the Google Classroom API, a 403 error is returned when I try to add the attachment to the student's submission.
GoogleJsonResponseException:
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "#ProjectPermissionDenied The Developer Console project is not permitted to make this request.",
"reason" : "forbidden"
} ],
"message" : "#ProjectPermissionDenied The Developer Console project is not permitted to make this request.",
"status" : "PERMISSION_DENIED"
}
The call is being made from an authenticated student account and being added as a Link resource. The Developer Console project DOES have the Google Classroom API enabled, and other calls to the Google Classroom API are working fine, such as courses.list and courses.courseWork.studentSubmissions.get. What am I missing? The same error is returned when using the Try it! app in the Google Classroom documentation site.
When modifying assignments/courseWork or student submissions, only the Developer console project that created those objects can modify them. This means that only projects that created the corresponding course work can modify them, otherwise a 403 PERMISSION_DENIED error is returned. You can easily determine if the course work item is associated with the Developer Console project making the request by checking the associatedWithDeveloper property on the Google Classroom course work response.
It took me a while to figure this out myself, but the best way to go in my opinion is to first create the coursework (i.e. assignment or question) itself with Google Script or using the Classroom API. The coursework is then associated with the correct console project and you are cleared to manage the submissions from thereon.
All Classroom API methods may return a PERMISSION_DENIED (HTTP 403) error if an end user does not meet prerequisites for access. The message accompanying the error contains an error message to help you identify the cause and direct users to take the appropriate action.
ProjectPermissionDenied indicates that the request attempted to modify a resource associated with a different Developer Console project.
Possible Action: Indicate that your application cannot make the desired request. It can only be made by the Developer Console project of the OAuth client ID that created the resource.

Resources