Learn JavaScript on the Now Platform: Lesson 36 - Scripted REST APIs

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024
  • This lesson builds on the skills you've learned thus far to create a custom REST API using a ServiceNow Scripted REST API. You'll learn about REST services and resources as well as how to pass information to your REST resource and return a result. This lesson also covers the basics of the REST API Explorer to help test your code.
    GitHub Repo: bit.ly/sn-js

ความคิดเห็น • 29

  • @kaila2880
    @kaila2880 2 ปีที่แล้ว +1

    wanna see all scripts? :)
    Script 1 4:42 GET (Hello world)
    Script 2 7:27 GET (query params)
    Script 3 11:25 GET (path params)
    Script 4 14:35 POST (request body payload)
    Script 5 18:25 POST (request body payload + response body payload)
    btw - thanks Chuck, great work!

  • @williammadisondavis
    @williammadisondavis 5 ปีที่แล้ว +4

    Thank you for the HUGE contribution to everyone attempting to learn this massive application! So helpful, informative and easy to follow.

    • @ChuckTomasi
      @ChuckTomasi 5 ปีที่แล้ว +1

      You are very welcome Will. Thanks for watching!

  • @jerryjohn257
    @jerryjohn257 4 ปีที่แล้ว +1

    Chuck I like the way you present the content . You are an exceptional talent . GOD BLESS

    • @ChuckTomasi
      @ChuckTomasi 4 ปีที่แล้ว

      Thank you J J. I'm glad you enjoyed it.

  • @devs0810
    @devs0810 5 ปีที่แล้ว +1

    Thanks Chuck..
    The entire tutorial is pure Gold..

  • @anilkumarmohanty2077
    @anilkumarmohanty2077 3 ปีที่แล้ว

    Excellent one Chuck...Very well explained

  • @karuna128
    @karuna128 5 ปีที่แล้ว +2

    very well done chuck. Appreciate your effort

  • @bernarda.moralesnicola7799
    @bernarda.moralesnicola7799 3 ปีที่แล้ว +1

    Very "FUN" video. Thanks !!!

  • @jjp5619
    @jjp5619 5 ปีที่แล้ว +1

    Very helpful. I have been looking for something like this!!

    • @ChuckTomasi
      @ChuckTomasi 5 ปีที่แล้ว

      Thank you. I'm glad you found it useful

  • @SoorajSinghBaghel
    @SoorajSinghBaghel 5 ปีที่แล้ว +2

    Thanks a lot Chuck

    • @ChuckTomasi
      @ChuckTomasi 5 ปีที่แล้ว

      You are welcome.

  • @meryemLux
    @meryemLux 3 ปีที่แล้ว +1

    Very informative! Thanks^^

    • @ChuckTomasi
      @ChuckTomasi 3 ปีที่แล้ว

      You are welcome. Thank you for watching.

  • @sttpt
    @sttpt 4 ปีที่แล้ว +1

    Very helpful...Thanks....

    • @ChuckTomasi
      @ChuckTomasi 4 ปีที่แล้ว

      You are very welcome. Thanks for watching.

  • @Freak512
    @Freak512 ปีที่แล้ว +1

    I didn’t understood what is queryparms

  • @HumaAzIman
    @HumaAzIman 3 ปีที่แล้ว

    Very Helpful.

  • @detlefbiedermann7174
    @detlefbiedermann7174 4 ปีที่แล้ว

    Hello, great tutorial, many thanks, one question: script 5 does not change the result when I:
    var answer = {};
    answer.status = "OK";
    answer.author = "system";
    answer.item = {"name" : "Rome", "owner" : "Chuck Tomasi", "count" : 12};
    answer.active = true;
    //response.setBody(answer);
    //return response;
    return answer;
    So the "setBody()" command seams not to be necessary ?

    • @ChuckTomasi
      @ChuckTomasi 4 ปีที่แล้ว

      I have found that using response.setBody() makes it easier to read later "Hey, this is the object I am sending back". returning an objection is implicit and possibly confusing. Additionally, best practice suggests using getters and setters to avoid inferred things happening or missing things that the API can provide.

  • @havieshkosuru8998
    @havieshkosuru8998 4 ปีที่แล้ว

    is it any standard to use "body.data" for defining POST variables? and queryParams = request.queryParams; GET method variables. why we are defining them in different way

    • @ChuckTomasi
      @ChuckTomasi 4 ปีที่แล้ว

      While I don't have a definitive answer from the product managers, my inner developer says "path parameters and query parameters are both part of the URI, so the similarity there makes sense. You have simple key=value pairs for each. POST methods have a body that can be a complex object such as an array of objects. These are addressed as request.body, with the payload of the request body in the data object to handle these more complex data types." Just out of curiosity, if you were to create it, what would you have done?

  • @janakiramanss6214
    @janakiramanss6214 5 ปีที่แล้ว

    Hey how to call a external api inside Ajax call

    • @ChuckTomasi
      @ChuckTomasi 5 ปีที่แล้ว

      Can you give me some specifics of what you are trying to do?

  • @amirmohamed4670
    @amirmohamed4670 ปีที่แล้ว +1

    Hi Chuck,
    Many thanks for your effort.
    I have a question.
    Why did we use here the dot notation method instead of getValue that you suggested that it's the best way to get the value of a record ?
    var isActiveQuery = queryParams.getValue("active");

    • @ChuckTomasi
      @ChuckTomasi ปีที่แล้ว

      Excellent question. getValue() is a method available to GlideRecord objects. queryParams is not a GlideRecord, therefore we cannot use getValue(). If you try it, you'll get an error stating that the system doesn't know what getValue() is.

    • @amirmohamed4670
      @amirmohamed4670 ปีที่แล้ว

      @@ChuckTomasi ​Oh my bad. Thank you for the clarification. I really appreciate your efforts.