Share via

Conversation Language Understanding API Resource Not Found

Zhang, Jayden 20 Reputation points
2023-11-17T15:08:49.41+00:00

I followed the document and created API access, posting queries but it returned 404 with the message 'resource not found'. Hope to get help

My codes:

def submit_job(text):
    data = {
          "kind": "Conversation",
          "analysisInput": {
            "conversationItem": {
              "id": "1",
              "participantId": "1",
              "text": text
            }
          },
          "parameters": {
            "projectName": f"{PROJECT_NAME}",
            "deploymentName": f"{DEPLOYMENT_NAME}",
            "stringIndexType": "Utf16CodeUnit"
          }
        }
    resp = requests.post(
        endpoint,
        headers=headers,
        json=data
    )
    return resp
    

#%% Azure call
PROJECT_NAME='Bond-parser-conversation'
DEPLOYMENT_NAME='merged_2'
API_VERSION='2022-10-01-preview'
endpoint = 'https://conversation-und.cognitiveservices.azure.com/language/:analyze-conversations?api-version={API_VERSION}' 

headers = { 
    'Ocp-Apim-Subscription-Key': 'xxxxxxxxxxxxxxxxxxxxx'
}
result=submit_job(text)

Azure Language in Foundry Tools
Azure Language in Foundry Tools

An Azure service that provides natural language capabilities including sentiment analysis, entity extraction, and automated question answering.

0 comments No comments

Answer accepted by question author

Azar 31,720 Reputation points MVP Volunteer Moderator
2023-11-17T18:19:45.1366667+00:00

Hi Zhang, Jayden

Try this u[dated code below

def submit_job(text):
    data = {
        "kind": "Conversation",
        "analysisInput": {
            "conversationItem": {
                "id": "1",
                "participantId": "1",
                "text": text
            }
        },
        "parameters": {
            "projectName": f"{PROJECT_NAME}",
            "deploymentName": f"{DEPLOYMENT_NAME}",
            "stringIndexType": "Utf16CodeUnit"
        }
    }
    resp = requests.post(
        endpoint,
        headers=headers,
        json=data
    )
    return resp


PROJECT_NAME = 'Bond-parser-conversation'
DEPLOYMENT_NAME = 'merged_2'
API_VERSION = '2022-10-01-preview'
endpoint = f'https://conversation-und.cognitiveservices.azure.com/language/analyze-conversations?api-version={API_VERSION}'

headers = {
    'Ocp-Apim-Subscription-Key': 'xxxxxxxxxxxxxxxxxxxxx'
}

text = "Your conversation text here."  # fill your convo here 
result = submit_job(text)


  • : Removed the colon : from the endpoint path.
  • Used an f-string to dynamically construct the endpoint URL with the API version.
  • Added a placeholder text for the conversation. Replace it with your actual conversation text when calling submit_job. from the endpoint path.

Hope this helps, kindly accept the answer if you find it useful thanks much.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.