1

Really hope someone can assist, we are using Azure Mobile App Service and everything works fine in the editor and on IOS, we only have a problem on Android when trying to update an existing record.

According to the Azure resource documentation you need to use Patch

PATCH /tables/tablename/:id Update an existing record in the table

When testing on an Android device it does not even try to send the web request it simply returns error: "Unsupported Protocol"

The research shows that there are workaround solution but I have not found anything relevant to Unity.

I did a search on the forum for HttpMethod.Patch but could not find a single article. Really having some trouble understanding how to resolve the issue and if there is a way to resolve it in Unity.

Any help would be greatly appreciated.

Just thought I would add this, according to the Unity documentation found here: https://docs.unity3d.com/Manual/UnityWebRequest.html

Platforms supported in 5.3:

Mobile Platforms: iOS, Android, Windows Phone 8

Set HTTP verb (GET, POST, HEAD, etc.)

Custom verbs are permitted (So we added Patch)

This should work no problem, but it does not even try to do the UnityWebRequest it just returns the error: 'Unsupported Protocol'

Seeing that the official documentation states that this should work, could this be a bug in UnityWebRequest?

Thanks in advance.

P.S. we have posted this on http://answers.unity3d.com/questions/1230067/trying-to-use-patch-on-a-unitywebrequest-on-androi.html and we haven't heard any reasons, that is why i am posting the question here. Please if anyone knows anything about this topic to shed some light.

1
  • I'm from the Azure Mobile team. Unfortunately, we don't support using Unity to make web requests, only the Azure Mobile Android SDK. It is open source however, so you might be able to do some digging yourself: github.com/azure/azure-mobile-apps-android-client
    – lindydonna
    Aug 25, 2016 at 18:52

3 Answers 3

1

According to the API reference of UnityWebRequest, it seems to not support PATCH verb by default, besides following the definition of PATCH verb to construct a request with method PATCH and other parameters in UnityWebRequest. It's just my understanding above, because I could not find any information about PATCH verb with UnityWebRequest.

However, according to the issue information Unity Web Request and Json Utility, you can try to follow the GitHub project that using UnityRestClient instead of UnityWebRequest to update Azure Mobile App table record.

Hope it helps.

3
  • Thank you so much for getting back to me. we have actually been using a custom library that can be found HERE. And basically built our entire game with this, so that means that we will have to replace most of our code. Having said that we for a short cut we are going to try to use use one function for this new "SDK". Thank you extremely much for providing it. Aug 19, 2016 at 10:33
  • Thank you very much for your suggestion. Unfortunately we cannot figure out how the UnityRestClient works as there are no code examples. We tried reverse engineering it using the Github project, but the mobile component requires an app key which Azure no longer uses, so we cannot get it to work. We managed to get Unity involved and at first the confirmed it as a bug and set out to fix it, however they have come back to us and said that this is by design as android does not support the PATCH verb due to security reasons. Aug 24, 2016 at 13:14
  • Here are the details Link. Is there another way that we could updated an entry without using PATCH? Would it be possible to pass data to an api call to do the update server side? Aug 24, 2016 at 13:17
1

Azure SDK for Android uses okHttp library, which supports PATCH. However, Unity's webrequest uses native Android networking which does not support PATCH. Just made a simple workaround using Easy APIs: https://github.com/dgkanatsios/AzureServicesForUnity

1
  • My friend Jean asked me to relay the message. He has tested it and it works 100% Thank you so much for coming up with this solution. We can move forward now and launch on two platforms. Your a Rock Star. Sep 4, 2016 at 16:36
0

One workaround is to install "method-override" which works with Azure App Services (node backend).

  1. Add "method-override": "^2.3.7" to your "package.json" dependencies by running:

    npm install method-override --save

  2. Insert the following to your "app.js" express app config (this is explained in the method-override readme)

    var methodOverride = require('method-override');

    Then after the line var app = express(); add:

    app.use(methodOverride('X-HTTP-Method-Override'))

  3. Now change your update request from "PATCH" to "POST" and add the header:

X-HTTP-Method-Override: PATCH

Then enable the x-http method override header and allow you to send a POST request on Android which will be seen as a PATCH request - this will process the update successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.