Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Roelof 5 posts 76 karma points
    Jul 24, 2016 @ 08:55
    Roelof
    1

    where do I put a call to a external api

    Hello,

    Im learning asp.net mvc and Umbraco on this moment.

    Now Im trying the following.

    I have to read some pictures from a external api and place them on the front-page. There are a lot some 2000

    I have to do three steps to make this work.

    1) Get all the images numbers from the external api.

    2) With that number I can ask on another url for the image data like the author,

    3) With that number I can ask on yet another url for the image so I can post it.

    Where do I put the code that calls all the data and what is the most efficient way to make this all work so it will not take hours to get all the data.

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jul 25, 2016 @ 20:46
    Alex Skrypnyk
    0

    Hi Roelof,

    Welcome to Our!

    It looks like the best way to get images will be some external worker, ot just check on the start of application do you have images locally or no.

    If no - download them asynchronously.

    If you need image per page - another solution will be download image per page when page will be requested, look at RenderMvcController - https://our.umbraco.org/documentation/reference/routing/custom-controllers

    The main question how will you show images on the site?

    Thanks,

    Alex

  • Roelof 5 posts 76 karma points
    Jul 26, 2016 @ 09:59
    Roelof
    0

    Hallo,

    Thanks for the help. I like to display 10 images aan page because the api sends that number on every respons

    The image is also a link to a detail page

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jul 26, 2016 @ 10:02
    Alex Skrypnyk
    0

    Roelof, is your api slow? Should you call api async or no?

    Thanks

  • Roelof 5 posts 76 karma points
    Jul 26, 2016 @ 10:15
    Roelof
    0

    The api is not slow but ik need to make 3 request every image.

    1 request retrieving the image number so for 4700 there wil be 470 request.

    Then for every image i need to do 2 request. One for the image andere one for the image data

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jul 26, 2016 @ 10:19
    Alex Skrypnyk
    0

    Roelof, I think you need to download all images, if it's possible to your local machine and show from local.

    Or call api asynchronously, it will be faster.

  • Roelof 5 posts 76 karma points
    Jul 26, 2016 @ 14:20
    Roelof
    0

    Oké, so first make a request for the 10 numbers and then in the response ask for the other two. So nest three async request

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jul 26, 2016 @ 14:39
    Alex Skrypnyk
    0

    Yes, try it, how many time it will take.

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jul 28, 2016 @ 11:41
    Alex Skrypnyk
    0

    Hi Roelof,

    Did you solve the problem ?

    Thanks

  • Roelof 5 posts 76 karma points
    Jul 28, 2016 @ 12:15
    Roelof
    0

    Nope, still figure out how the async stuff works and im now on holiday so no box for development right now

  • Wilson 14 posts 103 karma points
    Jul 31, 2017 @ 10:30
    Wilson
    0

    So what is the answers for where to put the code to call external API to get data ?

    Thanks.

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jul 31, 2017 @ 14:11
    Alex Skrypnyk
    0

    Hi Wilson

    Try to put your code to App_Code folder or if it's Web Application project - Controllers folder.

    Can you share what code are you using?

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft