Search the Community
Showing results for tags 'unity'.
-
Can anyone help with this please? I am learning Unity and the emby api, and diving in well past the deep end.. I am getting a 400 bad response when trying to use "/emby/Users/AuthenticateByName" when i manually use the same headers and json data on the http://swagger.emby.media page, i get a successful response. from that i understand i need to set a header and post some json data i can get a successful response in Unity from simpler api methods like /System/Info which dont require posting json and setting headers. anyone out there got a unity app to work on the api? that could a post a unity example on using /emby/Users/AuthenticateByName sucessfully (or something similar with headers and json? using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; public class EmbyAPIComp : MonoBehaviour { [System.Serializable] public class MyClass { string Username = "MyUsername"; string Pw = "Mypassword"; } static MyClass myObject = new MyClass(); string json = JsonUtility.ToJson(myObject); IEnumerator AuthenticateCoroutine() { using (UnityWebRequest www = UnityWebRequest.Put("http://192.168.0.10:8096/emby/Users/AuthenticateByName", json)) { www.method = UnityWebRequest.kHttpVerbPOST; www.SetRequestHeader("X-Emby-Authorization" , "Emby UserId='91d851f075f44ae59bc499bc4ebb54e6', Client='Android', Device='Samsung Galaxy SIII', DeviceId='NickskApp', Version='1.0.0.0'"); www.SetRequestHeader("accept" , "application/json"); www.SetRequestHeader("Content-Type" , "application/json"); yield return www.SendWebRequest(); if(www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log(www.responseCode); } } } thanks for your help