Intro to REST API calls with Powershell

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

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

  • @CodeDoge
    @CodeDoge  4 года назад +5

    Link to Project FIles :
    REST API call with No Auth :
    github.com/jc566/RUclips_Solutions/blob/master/Powershell%20Scripts/REST%20API%20intro/GET/RestAPI%20Calls%20-%20No%20Auth%20Token.ps1
    REST API call with Auth & Personal Access Token :
    github.com/jc566/RUclips_Solutions/blob/master/Powershell%20Scripts/REST%20API%20intro/GET/RestAPI%20Calls%20-%20With%20Auth%20Token.ps1
    Important Time Stamps
    0:33 - Quick explanation of URL endpoints
    1:17 - Setting up URL
    2:36 - Creating query string
    3:19 - Result of API call with GET method
    3:43 - Some examples of how to digest the data retrieved
    5:19 - Creating Azure Devops Authorization token
    6:44 - Updating query string for API call with Personal Access Token
    9:19 - Create the token pairing
    10:42 - Creating the header variable
    11:15 - Quick breakdown of what to expect from running API call with PAT
    12:02 - Showing the usefulness of "-depth" parameter
    Link to HTTP Request Methods :
    developer.mozilla.org/en-US/docs/Web/HTTP/Methods
    Cat Facts API :
    alexwohlbruck.github.io/cat-facts/docs/
    Azure Devops API Documentation :
    docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/variablegroups/get%20variable%20groups?view=azure-devops-rest-5.1

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

    Great video!!
    I used this video to understand concepts of REST API with PowerShell and then asked ChatGPT the proper PowerShell-related questions to help guide me perform ETL on a cloud-based database.

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

      awesome glad it helped. I assume chatgpt will make me obsolete in no time...fml hopefully Im still around when AI takes over

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

    The code shown at 3:28 didn't work for me. It said "The variable 'response' is assigned but never used." I had to add Write-Output $response. How is this possible? Thank you for the video, btw...

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

      Im not sure what difference you might have but for that time stamp if you select the entirety of line 5 and press F8, it should populate the variables $response with the value of the 'Invoke-RestMethod'.
      If you are using 'write-host $response' or 'write-output $response' and the value of $response is empty, that means it hasnt properly ran the code since its just an empty variable. It should contain the result of the 'Invoke-RestMethod'

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

    Hmm, I will try this...I'm more focused on security aspect using powershell(windows 10 pro) and the linux instance/image you can download through the windows playstore. I use tools like Putty. Random rant, but I'm just sharing all this in case you also one want to go over how windows pro users can also do some linux stuff and/or use cases of Putty , and/or powershell means to try encryption,hashing, etc. No expectations, no obligations, but just a thought.

    • @CodeDoge
      @CodeDoge  4 года назад +1

      I definitely want to do more for windows/linux, but my will power is constantly stomped out by laziness. One day hopefully

    • @Jaemon4Eva
      @Jaemon4Eva 4 года назад +1

      @@CodeDoge universal struggle

    • @CodeDoge
      @CodeDoge  4 года назад +1

      @@Jaemon4Eva this be the real true true

    • @Jaemon4Eva
      @Jaemon4Eva 4 года назад

      @@CodeDoge lol

  • @mdsajjadurrahman9510
    @mdsajjadurrahman9510 3 года назад +3

    Thanks a lot! Its a really great intro!

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

      I'm glad you like it! hope it was helpful

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

    Love powershell. Thank you needed this tutorial

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

      just glad it was helpful!

  • @aeroic.2017
    @aeroic.2017 4 года назад +5

    THANK YOU!

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

    Such a great explanation. Thank you! Are there any videos for POST method and all?

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

      Hey thanks for the kind words. Im working on the next video to cover post + other http methods. Just busy with my day job. Ill follow up in this comment when the other videos up!

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

      @@CodeDoge Thanks a lot for your time. As I am new to powershell ,I am in need of some help related to this with respect to my project. Is there any possibility to get your support?

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

      @@divyalathamadapuri1754 Want to split that paycheck ;) jokes aside, I dont provide personal help for obvious reasons, but I cant try and see what I can do with a follow up post video

  • @suretricks
    @suretricks 4 года назад +3

    Thank you, great video!

    • @CodeDoge
      @CodeDoge  4 года назад

      just glad it helped!

  • @whoaMI-mi9hb
    @whoaMI-mi9hb 3 года назад

    Can you pls add a session to show - once Data fetched from REST API in Json format thru PS, how to save the the filtered data in excel or csv ! Im using Postman to access Endpoints and then get the ready to use PS cmdlt from Postman snippets inside PS ISE. But need to understand the logic to fetch the required amount of Data from huge JSON body and then save filtered data in excel or csv for reporting purpose

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

      Maybe I can make your request a future video, but for now, just save the object received from an API call as a object and convert to json. Then open a file and write into the file. There is a powershell module called PSExcel that should help you with Excel specifically.

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

    I am getting error - the remote server returned an error :401 unauthorised

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

      Make sure you are using a valid Personal Access Token

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

      @@CodeDoge yes token is correct . I have tried everything still facing this. We are trying to call SonarQube API from Powershell

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

      @@aronichakraborty5192 Depending on the API call being made, the user in which the PAT is authenticating as might require additional access within SonarQube portal. Difficult to help you out without screen share lol. But ultimately these are the steps required to make a api call. An issue about forbidden access with a valid PAT is likely because you PAT doesnt have access rights to perform an action. Similar to how I overviewed that Azure Devops PAT creation gives so many options to access rights, SonarQube is likely the same concept.

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

    🙏
    Bless & thanks

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

      glad it helped!!

  • @cylee604
    @cylee604 4 года назад +3

    👍