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

Поделиться
HTML-код
  • Опубликовано: 26 дек 2024

Комментарии • 51

  • @aussieraver7182
    @aussieraver7182 Год назад +1

    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 года назад +1

    Action speaks louder than words. Cool~

  • @babdie
    @babdie 5 месяцев назад +2

    "Are you reviewing headsets or cows" Type video music😂

  • @XilofononeXinining
    @XilofononeXinining 2 года назад +4

    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)

  • @erickr199
    @erickr199 2 года назад +1

    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

  • @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.

  • @visitor_t-w3p
    @visitor_t-w3p 5 месяцев назад +1

    Thank u so much..excellent video 😍😍🤩🤩🤩

  • @jfiascaro
    @jfiascaro 2 года назад +1

    How can we send the secret and public keys for security connection?

  • @shurvirmori
    @shurvirmori 3 года назад +1

    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 года назад +1

      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 - ruclips.net/video/g0k4XStzkLQ/видео.html

  • @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 года назад +1

      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.

  • @restushlogic5794
    @restushlogic5794 Год назад

    do you know what kind of service that I can manage my own json for free or cheap?

  • @chamilagayan2593
    @chamilagayan2593 2 года назад

    I got this error while get data - HTTP/1.1 405 Method Not Allowed

  • @NHGeneral
    @NHGeneral 3 года назад +1

    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 года назад +2

      yes, since this is a http request.

  • @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 Год назад

      JsonConvert.SerializeObject

  • @luyangzou6479
    @luyangzou6479 3 года назад +1

    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.

  • @blockchaingames1987
    @blockchaingames1987 3 года назад +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.

  • @ItsYourBoPhase
    @ItsYourBoPhase 3 года назад +2

    Can you use a POST to upload an image file?

    • @Unity3DSchool
      @Unity3DSchool  3 года назад +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?

  • @deflatedbraincell
    @deflatedbraincell 2 года назад

    Hi, what if the json data is nested, for example:
    {
    "user": {
    "userID": "1234",
    "username": "testuser",
    }
    }

    • @rapideye101
      @rapideye101 Год назад +1

      write a class which has that format and deserialize from JSON into this class, the class has to be [System.Serializable]

  • @BahadrCAKARhosgeldin
    @BahadrCAKARhosgeldin 2 года назад

    So can we play a unity project with the same way mate?

  • @codebreaker2590
    @codebreaker2590 2 года назад +1

    How to get my own weblink

  • @yourlocalgamedev1834
    @yourlocalgamedev1834 3 года назад

    Hey how could I use web request to get texture?

  • @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 года назад +2

      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 :)

  • @codebreaker2590
    @codebreaker2590 2 года назад

    Its only work if we use your web

  • @dmytromahas9207
    @dmytromahas9207 2 года назад

    Thanks for this useful tutorial, you've helped me so much!

  • @karimhajsalah6251
    @karimhajsalah6251 3 года назад

    hi , how to post data in webserver

    • @Unity3DSchool
      @Unity3DSchool  3 года назад +1

      Posting data is also demonstrated in video.

  • @MrZtapp
    @MrZtapp 2 года назад

    Very good, thanks.

  • @Pranav9894
    @Pranav9894 2 года назад

    Thank you soo much man

  • @fatihay2328
    @fatihay2328 2 года назад +1

    thanks man

  • @denyandriana9169
    @denyandriana9169 3 года назад +1

    Thank you

  • @marcelopc7283
    @marcelopc7283 3 года назад +1

    muchas gracias!

  • @leeoiou7295
    @leeoiou7295 2 года назад +1

    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 года назад +1

      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 года назад +3

      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.

  • @Sir-Prakarn
    @Sir-Prakarn 3 года назад +1

    Thank you so much

  • @gaffarwanitek7508
    @gaffarwanitek7508 2 года назад

    You might be good with networking but a very bad Unity programmer XD