Gildas Bng
Gildas Bng

Reputation: 47

UnityWebRequest and Azure Bot issue

I am currently trying to link a Unity application to my bot messaging endpoint in portal Azure. To do this, I use a UnityWebRequest.GET call as explained in Unity doc (https://docs.unity3d.com/Manual/UnityWebRequest-RetrievingTextBinaryData.html).

The fact is that I always encounter the same issue when I launch the app: The HTTP 'GET' method is not supported by the 'GenericJsonWebHookReceiver' WebHook receiver

I have no idea of how or where do I have to make changes in order to solve this. Does anyone facing the same issue?

Here is my code:

IEnumerator GetText()
{
    UnityWebRequest www = UnityWebRequest.Get("<messaging endpoint of the bot>");
    yield return www.Send();

    if (www.isError)
    {
        Debug.Log(www.error);
    }
    else
    {
        // Show results as text
        Debug.Log(www.downloadHandler.text);

        // Or retrieve results as binary data
        byte[] results = www.downloadHandler.data;
    }
}

Upvotes: 1

Views: 376

Answers (1)

Eric Dahlvang
Eric Dahlvang

Reputation: 8292

The error you are seeing doesn't have anything to do with Unity, but https://[YourBotId].azurewebsites.net/api/messages is not callable via Get, it is a Post method. If you navigate to the /api/messages path in a browser, you'll see the same error message.

enter image description here

Have you tried Posting an Activity to the messages endpoint?

I haven't tried this out, but maybe it can help you: https://github.com/tompaana/bot-direct-line-for-unity

Upvotes: 1

Related Questions