Get/Post REST API Data using UnityWebRequest | Unity Game Engine

  Рет қаралды 46,810

Unity3D School

Unity3D School

3 жыл бұрын

Copy code from here-
u3ds.blogspot.com/2021/01/get...
Feel free to Like and Share to show support for this channel.
Don't forget to leave a comment if anything comes to mind.
Have a nice day :)
#unity #rest #api

Пікірлер: 49
@aussieraver7182
@aussieraver7182 10 ай бұрын
I didnt realise you could do this sort of stuff. When I found out years ago, it blew my mind with the amount of integration you can perform.
@minmyatzawmoe5023
@minmyatzawmoe5023 2 жыл бұрын
Action speaks louder than words. Cool~
@dmytromahas9207
@dmytromahas9207 2 жыл бұрын
Thanks for this useful tutorial, you've helped me so much!
@MrZtapp
@MrZtapp 2 жыл бұрын
Very good, thanks.
@erickr199
@erickr199 2 жыл бұрын
Anyone knows of a tutorial of how to do it the other way around? i have and application which has to post information into unity using rest
@Pranav9894
@Pranav9894 Жыл бұрын
Thank you soo much man
@NewbNinjas
@NewbNinjas Жыл бұрын
How do you actually POST it though? I'm trying to upload a file to my web hosting, I can retrieve it and display it using the GET method but the POST method doesn't work, just says forbidden if I define the directory only where my handle_post.php file is, or if I specify the actual php file, it says error 404. I'm confused. Any help would be deeply appreciated.
@shurvirmori
@shurvirmori 3 жыл бұрын
No matters, How much subscribers.... This Video Matters which is very Easy to understand and start me with Rest API. Thanks bro :) ☺
@shurvirmori
@shurvirmori 3 жыл бұрын
But How to access data which I got in JSON?, kindly make video on this too.
@Unity3DSchool
@Unity3DSchool 3 жыл бұрын
I will surely create a video on this topic. Meanwhile you can check this video for JSON Deserialization - kzbin.info/www/bejne/nWHOZYuJqd-egrM
@blockchaingames1987
@blockchaingames1987 2 жыл бұрын
It works for me. Its shows me the JSON Data but i just want to show a specific part of the API and not all information. Can you share how to do JsonUtility.FromJson(json) after Web request. Thank you.
@marcelopc7283
@marcelopc7283 3 жыл бұрын
muchas gracias!
@jfiascaro
@jfiascaro 2 жыл бұрын
How can we send the secret and public keys for security connection?
@XilofononeXinining
@XilofononeXinining Жыл бұрын
How to resolve that? I receive this at 2:10 instead-> NullReferenceException: Object reference not set to an instance of an object GetMethod+d__3.MoveNext () (at Assets/GetMethod.cs:21) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) GetMethod:GetData() (at Assets/GetMethod.cs:17) UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
@NitishBeejawat
@NitishBeejawat 7 ай бұрын
Facing same issue. Have you solved it?
@fatihay2328
@fatihay2328 2 жыл бұрын
thanks man
@denyandriana9169
@denyandriana9169 3 жыл бұрын
Thank you
@yourlocalgamedev1834
@yourlocalgamedev1834 3 жыл бұрын
Hey how could I use web request to get texture?
@NHGeneral
@NHGeneral 3 жыл бұрын
Hi Unity3D School, I am new to Unity and have not much knowledge about webserver, my case is: I have a LAMP set up in my Raspberry Pi 4, and it working fine. I can open phpmyadmin page on Raspi on my PC's browser. I need to make an very simple mobile app to trade data with Raspi for Home management usage. Does the method mentioned in this work with my config? If not, please tell me what I need to do, or just change the concept. Please help.
@thereborne5219
@thereborne5219 2 жыл бұрын
yes, since this is a http request.
@restushlogic5794
@restushlogic5794 Жыл бұрын
do you know what kind of service that I can manage my own json for free or cheap?
@BahadrCAKARhosgeldin
@BahadrCAKARhosgeldin 2 жыл бұрын
So can we play a unity project with the same way mate?
@chamilagayan2593
@chamilagayan2593 Жыл бұрын
I got this error while get data - HTTP/1.1 405 Method Not Allowed
@hank8913
@hank8913 3 жыл бұрын
Sry for asking a question , I was following ur steps (PostData) and then Unity returns my start not set to an instance of an object (All codes are correct ) What is goning on here ? :(
@Unity3DSchool
@Unity3DSchool 3 жыл бұрын
I have to see your code to find the exact reason but if the error is in Start then my guess is that the gameobject with the given name is not found in the scene. Check if the name is exactly the same.
@bomxacalaka2033
@bomxacalaka2033 2 жыл бұрын
How can I GET request all the text from the box, basically the reverse of what you did in the video.
@gorik333
@gorik333 7 ай бұрын
JsonConvert.SerializeObject
@nabilhamouda1472
@nabilhamouda1472 3 жыл бұрын
hello :) this method really good and works good for me but in my case I am using unity3d and azure ,,, so I want the text to appear in TextMeshPro component which I add to SlateUGUI ,,, so i just i dont know how to modify the script with that cause i tryed but doesnt work ..i hope you can help me
@Unity3DSchool
@Unity3DSchool 3 жыл бұрын
Replace InputField with TextMeshPro. If it is still not working then I suggest you to search online "setting text of TextMeshPro in Unity" or something like this. You will surely find the solution.
@nabilhamouda1472
@nabilhamouda1472 3 жыл бұрын
@@Unity3DSchool It works well for me now thank you, just one question please... I have different texts which I put it in Json file and put it on server ,,, and i want to get them like here in this video, how can I modify the Script ? if I want to add 2 buttons next and previous to pass from text to other how can i add them to script ? really hope you can help me with that cause it s important for me and thank you so much :)
@deflatedbraincell
@deflatedbraincell Жыл бұрын
Hi, what if the json data is nested, for example: { "user": { "userID": "1234", "username": "testuser", } }
@rapideye101
@rapideye101 Жыл бұрын
write a class which has that format and deserialize from JSON into this class, the class has to be [System.Serializable]
@Sir-Prakarn
@Sir-Prakarn 2 жыл бұрын
Thank you so much
@ItsYourBoPhase
@ItsYourBoPhase 2 жыл бұрын
Can you use a POST to upload an image file?
@Unity3DSchool
@Unity3DSchool 2 жыл бұрын
Yes. You can covert image into either binary or base64 string. After that you can send the binary/string with POST body. Never tried it but it should work. Will make a video on it. 😁
@beneilton1000
@beneilton1000 Жыл бұрын
@@Unity3DSchool And a zip file is the same?
@codebreaker2590
@codebreaker2590 2 жыл бұрын
How to get my own weblink
@codebreaker2590
@codebreaker2590 2 жыл бұрын
Its only work if we use your web
@luyangzou6479
@luyangzou6479 3 жыл бұрын
how to check the post data is working ?
@Unity3DSchool
@Unity3DSchool 3 жыл бұрын
isHttpError or isNetworkError will return true in case there is problem in posting data.
@luyangzou6479
@luyangzou6479 3 жыл бұрын
@@Unity3DSchool Thanks, I tried that post button, it sends 4 as the data, but where I can change it and where it will be showing? since the URL inside the code is the 'get' function URL?
@jimbaub
@jimbaub 3 жыл бұрын
@@luyangzou6479 You can send a POST request to the same URL and the server will process it differently. If you run a GET request and see there are 4 items, then you run a POST to the same URL and it's set up to handle them, you should be able to run the GET request a second time and see 5 items.
@karimhajsalah6251
@karimhajsalah6251 3 жыл бұрын
hi , how to post data in webserver
@Unity3DSchool
@Unity3DSchool 3 жыл бұрын
Posting data is also demonstrated in video.
@gaffarwanitek7508
@gaffarwanitek7508 2 жыл бұрын
You might be good with networking but a very bad Unity programmer XD
@leeoiou7295
@leeoiou7295 2 жыл бұрын
Your code is so bad! why are you searching for gameobjects by their name when you can serialize it and still make it private? SMH
@Unity3DSchool
@Unity3DSchool 2 жыл бұрын
This video is not about getting game object. I am just using one of the methods available to get the game object. Also think about it, if searching is so bad then why its still available to use. If I can not use searching here then where can I use it? think about it. Just don't use Find in every frame and you are good to go. docs.unity3d.com/ScriptReference/GameObject.Find.html
@leeoiou7295
@leeoiou7295 2 жыл бұрын
@@Unity3DSchool The reason searching is so bad is that if you are searching by name and you change the name of the gameobject then you could easily get a null reference. The reason I pointed this out is that beginners pick up a lot of programming habits from tutorials. So even if the video is not about getting gameobjects, someone could learn the wrong or inefficient method. Not only are you using Gameobject.Find(), you are also getting component when you could simply just assign it and still make it private.
@Unity3DSchool
@Unity3DSchool 2 жыл бұрын
The point is that you will get NRE if you change the name. No matter what method you use, there will always be 'what if..'. What If someone deletes the game object OR what if I delete the component OR What if I delete the tag etc. There is no bad code, only bad use. In this particular case, I found this the quickest way to do things, and at the same time, I demonstrated the use of Find. As for beginners, I will encourage them to learn about the Find, how to use it and why it should be used carefully. But thanks for mentioning this. I will try to be more careful in the future.
What is JSON?
7:00
Code Monkey
Рет қаралды 95 М.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 9 МЛН
УГАДАЙ ГДЕ ПРАВИЛЬНЫЙ ЦВЕТ?😱
00:14
МЯТНАЯ ФАНТА
Рет қаралды 3,5 МЛН
Displaying REAL-WORLD Weather in Unity (using REST APIs)
7:32
Unity3d - UnityWebRequest Get async tutorial
15:48
Coding with Carlos
Рет қаралды 26 М.
How to Use RESTful APIs In Unity [Unity Tutorial]
10:23
Comp-3 Interactive
Рет қаралды 46 М.
I Melted Wood With Friction
8:44
The Action Lab
Рет қаралды 996 М.
Sending Web Requests in Unity - UnityWebRequest
4:12
Tarodev
Рет қаралды 21 М.
What is a REST API?
9:12
IBM Technology
Рет қаралды 1,5 МЛН