how do I add a file source to an azure questions and answer project via REST?

ABE69 6 Reputation points
2024-02-07T08:00:16.95+00:00

I am trying to add a file source to an existing questions and answer project created with language studio

if I post this payload

[    {     "op": "add",     "value": {       "displayName": "source2",       "sourceUri": "https://download.microsoft.com/download/2/9/B/29B20383-302C-4517-A006-B0186F04BE28/surface-pro-4-user-guide-EN.pdf",       "sourceKind": "file",       "source": "surface-guide.pdf"     }   } ]

I get a 202 code but source is not added
I am on free tier but I only have 2 existing sources

Azure AI Language
Azure AI Language
An Azure service that provides natural language capabilities including sentiment analysis, entity extraction, and automated question answering.
358 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,393 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 15,676 Reputation points
    2024-02-07T11:20:16.58+00:00

    You didn't share enough information, bu t I assume you're on the right track by using the HTTP PATCH method with a payload that specifies the operation (op) as add, and provides the necessary details about the file source you want to add (value). However, if you're receiving a 202 Accepted status code but the source isn't being added, it might be for the following reasons : Are you sure that you have the correct endpoint for adding a source to your project? because the endpoint typically looks like this: https://api.{location}.language.azure.com/language/:query-knowledgebases/projects/{projectName}/sources where {location} is your Azure service location (example westus, eastus2) and {projectName} is the name of your QnA project. You must also confirm that your request includes a valid Authorization header with a Bearer token. Azure REST APIs require proper authentication, and missing or invalid tokens can lead to requests not being processed correctly. In your case, please be aware that use of PATCH is correct for modifying existing resources, including adding sources to your project must be aligned with the request method which needs to bes set to PATCH. The payload format seems correct for a PATCH operation, specifying the operation as add like the following :

    • displayName: A user-friendly name for the source.
    • sourceUri: The URL where the file can be downloaded.
    • sourceKind: The type of source, which is file in your case.
    • source: This should typically be the name you want to assign to this source for identification within your project, but it's not usually a required field for adding a file source. Confirm this field's purpose and whether it's necessary for your specific use case Please test and tell us :)