Excel VBA Introduction Part 47.5 - Basic HTTP GET and POST Requests

Sdílet
Vložit
  • čas přidán 4. 06. 2019
  • By Andrew Gould
    Download files here www.wiseowl.co.uk/vba-macros/...
    POST requests begins @33:37
    www.wiseowl.co.uk - This video explains the basic differences between the GET and POST methods and how you can use each method to send data along with an HTTP request. You'll learn about adding a query string to a URL for GET requests and how to send values in the body of a POST request. You'll also see how to ensure the values you pass to a request are properly encoded using the Excel EncodeURL function. You'll learn the basics of using the Chrome Developer Tools to work out how requests are sent by the Chrome browser to help writing your VBA code.
    If you'd like to help fund Wise Owl's conversion of tea and biscuits into quality training videos, you can click this link www.wiseowl.co.uk/donate?t=1 to make a donation. Thanks for watching!
    You can buy our Introduction to Excel VBA book here www.lulu.com/shop/andrew-gould...
    Visit www.wiseowl.co.uk for more online training resources in Microsoft Excel, SQL Server, Reporting Services, Analysis Services, Integration Services, ASP.NET, C#, Visual Basic, Microsoft Access, Microsoft PowerPoint, Microsoft Word, Microsoft Project, Microsoft Publisher, Microsoft Visio and more

Komentáře • 127

  • @AdamBowen93
    @AdamBowen93 Před 2 lety +4

    It's sad, but I am an amateur developer and have spent DAYS trying to get Excel to make an API Request to the US Census Bureau and it is only after watching this that I have succeeded. Thank you!!!

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 2 lety

      Hi Adam! Happy to hear that the video helped you, thanks for watching and taking the time to leave a comment!

  • @Aarmaxian
    @Aarmaxian Před 4 lety +1

    That is a fantastic video. Better than anything I have seen. Thank you very much.

  • @LearnYouAndMe
    @LearnYouAndMe Před 2 lety +3

    I liked the way you explain. You are just amazing providing advance stuff free of cost.

  • @paulucheoma9266
    @paulucheoma9266 Před 2 lety +4

    This was by far hands down one of the best videos I've watched on this topic. And it's free? Saying thank you isn't even enough! God bless you!

  • @joaofilipecastrosantos9947

    Your work is outstanding!!! And making it available for free is incredibly generous.

  • @sribalajispaceship
    @sribalajispaceship Před 4 lety +5

    You are the best!!!!!!! I am able to code and make my tasks automated after watching your videos..very simple ..clean..and elegant explanations

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 4 lety +1

      Thank you, Sri! Very happy to hear that you're enjoying the videos, thank you for the feedback and for watching!

  • @cesarchicaiza4831
    @cesarchicaiza4831 Před 3 lety +2

    You are my HERO good sir!!!, thanks so much for the awesome tutorials. Keep up the good work!!

  • @luisprieto5382
    @luisprieto5382 Před 4 lety +1

    Incredible tutorial. Thanks!

  • @krn14242
    @krn14242 Před 5 lety +2

    Great video Andrew. This is very useful information.

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 5 lety

      Thanks! It feels as though the VBA videos are gradually becoming more techy and narrowly focused. It's good to know that people still find them useful!

  • @LD-nx8oe
    @LD-nx8oe Před rokem +1

    Such exceptional videos. I will be donating within the next couple of days. Thanks so much.

  • @giuliko
    @giuliko Před 5 lety +1

    Wow... That's pure gold my friend. Thank you very much for that. God bless you.

  • @luizrvgo
    @luizrvgo Před 3 lety +1

    Amazing tutorial. Thanks, I've learned a lot!

  • @Got2bFit
    @Got2bFit Před 3 lety

    Thank you very much. Very informative tutorial.

  • @gianpaolo19
    @gianpaolo19 Před 4 lety +1

    Thank you very much!!!This is not gold but platinum!!Tanta ROBAAA si dice in Italia!!!!

  • @matthewyoung9250
    @matthewyoung9250 Před 3 lety +1

    Very clear, thank you!

  • @piotr780
    @piotr780 Před 3 lety +1

    you are best canal with VBA videos, this awful language will never die in corpo env, so you help us :)

  • @mumbai4862
    @mumbai4862 Před 3 lety +1

    So amazing and wonderful

  • @ashb899
    @ashb899 Před 5 lety +1

    This is some good shit man, good work

  • @hadibq
    @hadibq Před 2 lety

    Brilliant! all clear! TY ! 🙂

  • @sanjibpramanik9268
    @sanjibpramanik9268 Před 4 lety +4

    Thanks to make it easy, waiting for next tutorial, and also want to learn how to parse json by excel vba from you.

    • @wellskian5387
      @wellskian5387 Před 3 lety

      Dunno if anyone gives a damn but if you guys are bored like me during the covid times then you can watch pretty much all of the new series on InstaFlixxer. Been binge watching with my gf these days xD

    • @rhettulises4818
      @rhettulises4818 Před 3 lety

      @Wells Kian Yea, been watching on instaflixxer for since december myself :D

  • @simonjeras9269
    @simonjeras9269 Před 5 lety

    Hi,
    How to post # in the url request? system automaticaly replace with %23

  • @rajeshmajumdar4999
    @rajeshmajumdar4999 Před 5 lety

    Thank you so much 👍👍👍

  • @manideepu2817
    @manideepu2817 Před 4 lety

    Excellent.....
    One question on how to use Patch request like get and post?
    Any video or reference for that?

  • @pradeeprawatvlogs8358
    @pradeeprawatvlogs8358 Před 5 lety

    Thank you so much sir 🙏🙏🙏🙏🇮🇳

  • @ivbit
    @ivbit Před 5 lety +2

    Our admin said we have linups server (or something like that). Will this code work with linups server?

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 5 lety

      Hi there, I'm guessing your admin said Linux which I have no experience with so I'm sorry but I don't know!

  • @eldarikus
    @eldarikus Před 5 lety +1

    You are a wiz!

  • @Aarmaxian
    @Aarmaxian Před 4 lety

    If I use this in production to post and get data from a database (through a server), how can I protect the routes so that someone who gets hold of my workbook cannot see the data? I know this is a very unrelated question but I am really interested in knowing an answer to that one. Thanks.

    • @DM-py7pj
      @DM-py7pj Před 3 lety

      Nothing in Excel is secure except perhaps some of the Microsoft code.

  • @phoenixmoto5238
    @phoenixmoto5238 Před 3 lety

    Sir Andy Gould in this video,in subroutine parsewiseowlsearchresults to add image to sheet you have used addpicture and URL itself instead of first downloading and then refering to file path. So how this satisfies ?please comment

    • @DM-py7pj
      @DM-py7pj Před 3 lety

      The URL is still a "file path". docs.microsoft.com/en-us/office/vba/api/excel.shapes.addpictur

  • @dinhbaotran8827
    @dinhbaotran8827 Před rokem +2

    Cảm ơn bạn!

  • @mareklux9743
    @mareklux9743 Před 2 lety +1

    Thank you! Do you think it would be possible to load a site. Post username+password. Click Javascript button. Do until status confirmed it is loaded and then Navigate until you at your goal?

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 2 lety

      Hi Marek! I think that you'll have difficulty interacting with Javascript elements when using XMLHTTP requests. You may have more success automating a web browser such as Chrome using SeleniumBasic for VBA. You can see some videos on how to do this in this playlist czcams.com/play/PLNIs-AWhQzcl3xKvF8sVL4sWRWICj_clM.html
      I hope it helps and thanks for your support!

  • @MeTube2014
    @MeTube2014 Před 2 měsíci

    Is there a way to get an element by Xpath from a webpage in VBA but without installing Selenium?

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 2 měsíci

      Hi! Yes, you can use the MSXML2 library and use the SelectNodes method of a DOMDocument60 or XMLDocument object. Pass your XPath into the SelectNodes method.
      I hope it helps!

  • @shahbazkhan2283
    @shahbazkhan2283 Před 10 dny

    Hello Andrew,
    I am stuck. I can't find form data for any site. Where should i look.

  • @manikandanp1610
    @manikandanp1610 Před 2 lety

    Hi Andrew, Is there any way to interact website by using XML HTTP and HTML Library, Bz i could not see tag and data returning by http request as same like in browser for same website. Some tag and data missing in Http request because those are creating by script in browser. How this can be done?.

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 2 lety

      Hi Manikandad, if you need to interact with objects created by script in the browser then you'll need to automate a browser. We have some videos which explain how to do this in this playlist czcams.com/play/PLNIs-AWhQzcl3xKvF8sVL4sWRWICj_clM.html
      I hope it helps!

  • @Myrslokstok
    @Myrslokstok Před 2 lety

    I need an Oauth-token to retrive data is this comon?
    Can they be eternal valid time?

  • @RupeshKumar-ms8bl
    @RupeshKumar-ms8bl Před 3 lety

    Hey,
    The video was wonderfull.
    Can you please make a video to upload an image file to a server. Using POST multipart/form-data.

  • @LearnYouAndMe
    @LearnYouAndMe Před 2 lety

    Help - I dowloaded your file and ran BasicGETRequestWithQueryString but after opening text file in webbrowser it is showing nothing ( Just layout with no content).

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 2 lety +1

      It looks as though the CZcams example no longer works, probably due to changes in the way the site works since the video was recorded (this is always a problem when you're not in control of the site you're scraping). The other examples shown in the video still work.

  • @dharmaraju2908
    @dharmaraju2908 Před 4 lety

    Nice one ....can you please provide that macro

  • @rodrigoaraujo922
    @rodrigoaraujo922 Před 2 lety

    Hello, how are you? I really liked your explanation, but how do I show the field json below: I tried in several ways, but I couldn't.
    "physical capacity": [],

  • @thomasfergusen5144
    @thomasfergusen5144 Před 4 lety

    hello what is the disadvantages xlsb over xlsm

    • @DM-py7pj
      @DM-py7pj Před 3 lety

      www.google.com/search?q=xlsb+versus+xlsm

  • @mimocrocodile5069
    @mimocrocodile5069 Před 4 lety

    Hi. Thanks a lot.
    But I ran into a problem.
    In sub ParseBOEExchangeRates:
    HTMLString = "..." and after
    HTMLDoc.body.innerHTML = HTMLString
    HTMLDoc.body.innerHTML = begins with "

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 4 lety

      Hi Igor, did you try downloading the completed example file? This works correctly as shown in the video. You can find the link for this in the video description. I hope that helps!

  • @The_Code_Father
    @The_Code_Father Před rokem +1

    Awesome Tutorial Mr Andrew
    BTW i found alibrary for parsing and dealing with json files on github and i searched alot for detailed tutorials on how to use restful api's in excel vba and implement HTTP Requests using Excel VBA but I found nothing but very few tutorials about this topic
    The point that i have in my country a governmental E Invoice portal and they are using API and JSON files
    is there is anyway or any tutorial on how to do that using Excel vba and VBA JSON Parser library ??

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před rokem

      Hi! I'm sorry that's not something I have any experience of so I can't offer any useful advice.

    • @The_Code_Father
      @The_Code_Father Před rokem +1

      @@WiseOwlTutorials no problem sir thanks any way for those useful videos

  • @mr.r6373
    @mr.r6373 Před 3 lety

    How do i run subsequent xml requests ?
    ,when i open "SomeURL" on browser it runs other 267 subsequent requests(gets images &icons and JavaScript ), and gives output, but when i do with xml request, the response text only gives response for 1st,

    • @mr.r6373
      @mr.r6373 Před 3 lety +1

      Forgot to mention, you are my a true VBA guru, while watching other VBA Videos on CZcams i usually fast forward them but not with your videos , they are in great details and covers almost all possible scenarios related to it.❤️❤️

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 3 lety

      Hi Ravi, thanks for the kind words!
      I think the point of using XML HTTP requests is to avoid all of the other items that you've mentioned. The idea is to get only the response text of the initial request, not the results of javascript code, etc. If you want the results of the other items on the page then the best thing to do is use a web browser. I don't know if you've seen the recent videos on using Google Chrome from Excel VBA but there are several videos on the topic in this playlist starting at Part 57.1 czcams.com/play/PLNIs-AWhQzcl3xKvF8sVL4sWRWICj_clM.html
      I hope that helps!

    • @mr.r6373
      @mr.r6373 Před 3 lety

      @@WiseOwlTutorialsI am glad you responded ❤️, Yes i have seen chrome playlist, however due to organisation policy, IT department does not allow third party libraries/applications to install, hence can't use selenium.😭,

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 3 lety

      @@mr.r6373 That's so frustrating! I guess that the best option that you have is to use Internet Explorer (the videos which cover IE are in the same playlist I linked to above).

  • @zethlarsson4303
    @zethlarsson4303 Před rokem

    Thank you for an exelent lesson. English is not my basic language, but it was no problem to understand you.
    I'v one problem with you examples. The function WorkSheetFunction.EncodeURL do not work for me.
    Have tryed several suggestions from the web, but no one works.
    I would be very happy for some advice about what can be wrong in my environment.
    64 bit HP computer, Win11, Office 10.

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před rokem +1

      Hi Zeth! Happy to hear that you're finding the videos useful.
      Are you working with Office 2010? The EncodeURL function was introduced in Excel 2013 so if you're using an earlier version I'm sorry but it won't work.

  • @jjtagh
    @jjtagh Před 2 lety

    Would you consider doing a video on interacting with a GraphQL API using VBA?

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 2 lety

      Hi there! It's unlikely sorry, I don't know anything about GraphQL.

  • @AntrikshSharma
    @AntrikshSharma Před 5 lety +3

    9:50 you rapped there for few seconds, I see you can surpass Busta Rhymes.

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 5 lety +2

      😂 I don't think that any rapper has anything to worry about!

  • @Amr-Ibrahim-AI
    @Amr-Ibrahim-AI Před 4 lety

    Thanks for the great explanation. Very useful indeed.
    How may I send a binary file (an image, say) in a POST request?

    • @DM-py7pj
      @DM-py7pj Před 3 lety

      You want multipart/form-data e.g. stackoverflow.com/a/51453795

  • @deldube
    @deldube Před 4 lety

    Great instructional video. One of the best on CZcams for this software. Just have one question... See below:
    The last Post request from IMDB John Wick did not work. Can you assist as to why?

  • @MrMgrPL
    @MrMgrPL Před 3 lety

    Run-time error '91': Object variable or With block variable not set WTF?

  • @kashifkhanspecial
    @kashifkhanspecial Před 5 lety

    Hi Andrew,
    I have one request to you I have very large PowerPoint file and in the file have around 15 to 20 slides and I want to update these slides with the updated data and also adjust height and width etc, can you make tutorial that how to take a reference of any previous shapes and add new data and adjust accordingly.
    Thanks
    Kashif

  • @rayansalah5754
    @rayansalah5754 Před 3 lety

    Hi...I hope u make tutorial about oauth2 for vba

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 3 lety

      Hi there! We don't have any plans to make videos on this topic in the near future, sorry!

  • @KhalilYasser
    @KhalilYasser Před 5 lety

    In the `BasicPOSTRequestMultipleValues` procedure, it works but in the saved HTML file I didn't find the results. Although I manually did it in the browser and got results .. I even tried to copy all the source code of the POST but the same problem.

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 5 lety +1

      Hi Yasser, I'm finding the same thing. This is the problem with writing examples using websites: things change! At least we can still use GET requests to retrieve the information we need with this particular site!

    • @KhalilYasser
      @KhalilYasser Před 5 lety

      @@WiseOwlTutorials Thanks a lot for reply. I know things change all the time. But I tried to use GET also and the same problem. What are the things that have changed?

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 5 lety +1

      Hi Yasser, the GET request still works
      Sub BasicGETRequestIMDB()
      Dim req As New MSXML2.XMLHTTP60
      Dim reqURL As String
      reqURL = _
      "www.imdb.com/search/title/?" & _
      "title=john+wick" & _
      "&release_date=2018-01-01," & _
      "&genres=action"
      req.Open "GET", reqURL, False
      req.Send
      If req.Status 200 Then
      MsgBox req.Status & " - " & req.statusText
      Exit Sub
      End If
      'Debug.Print req.responseText
      SaveHTMFile req.responseText
      End Sub

    • @KhalilYasser
      @KhalilYasser Před 5 lety

      @@WiseOwlTutorials Thank you. I know things change all the time but when trying GET I got the same problem. What are the things that have changed? I didn't notice any change

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 5 lety

      The code I've posted in my previous reply works, I've just tested it. I don't know what changed because I don't work for IMDB!

  • @KhalilYasser
    @KhalilYasser Před 5 lety

    Thank you very much for this plenty of information. I have learned a lot.
    As for this part
    For n = 1 To 12
    MonthList.AddItem MonthName(n, True)
    Next n
    I got a list of months in Arabic. How can I made a list that generates months in English so as to make it work?

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 5 lety +1

      Hi Yasser, you can try this:
      Dim n As Long
      Dim EnglishMonthName As String
      For n = 1 To 12
      EnglishMonthName = Format(DateSerial(2019, n, 1), "[$-409]mmm")
      MonthList.AddItem EnglishMonthName
      Next n
      I hope it helps!

    • @KhalilYasser
      @KhalilYasser Před 5 lety

      @@WiseOwlTutorials I tried your code but the items in the MonthList combobox is still in Arabic ..

    • @KhalilYasser
      @KhalilYasser Před 5 lety

      I could solve that point using this code
      Dim aMonths As Variant
      aMonths = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")

      For n = 1 To 12
      MonthList.AddItem aMonths(n - 1)
      Next n
      But when trying to run the code, I got the message "Select a valid date"

    • @WiseOwlTutorials
      @WiseOwlTutorials  Před 5 lety +1

      Hi Yasser, you need the short month names "Jan", "Feb" etc.
      I hope that helps!

    • @KhalilYasser
      @KhalilYasser Před 5 lety +1

      @@WiseOwlTutorials Thank you very much. I applied your idea and used the short names for months but I still got the same message (invalid date). I debugged the code and I changed `MonthList.Text` To `MonthList.ListIndex + 1` and this worked fine now. Thanks a lot for your patience

  • @user-fp5xm2fu5f
    @user-fp5xm2fu5f Před 3 lety

    8:20