Using Valency API in content page

Options
Kwangsub.Ahn9052
Kwangsub.Ahn9052 Posts: 9 🌱
edited November 2022 in Development

I am trying to add a module of html page in Table of Content. I want to add a button in the page which uses valency API.

 

I am not sure how to accomplish this because I am struggling getting OAUTH token. I setup OAUTH application in setting. When I click the button in the page I made, it you redirect to oauth page and then I setup redirect_url in the same page in the module in Table of Content which is malfunctioning.

 

I don't think it's a right approach to do use valency API. Any good idea or suggestion?

Tagged:

Answers

  • Jordan.Snider3520
    Jordan.Snider3520 Posts: 42
    edited November 2022
    Options

    Hey @Kwangsub Ahn​ ,

     

    I think some samples or code repos may help you build the context of your app and receive the auth tokens you need to hit our APIs.

     

    Here are some ideas to help you get started:

     

    Hope that helps you start building your app :)

  • Kwangsub.Ahn9052
    Kwangsub.Ahn9052 Posts: 9 🌱
    edited November 2022
    Options

    testHi, Thanks for the reply. I made some progress but still has some issue. I am using API tool for test. Some of Get/Post methods works fine. But as the screenshot shown, uploading file throwing an error with 500. Not sure any thing wrong.

     

     

  • Jordan.Snider3520
    Jordan.Snider3520 Posts: 42
    edited November 2022
    Options

    Hey @Kwangsub Ahn​ ,

     

    I am not sure given your screenshot what exactly you are trying to do. The Data area of the API Test tool is where you enter JSON for the API call. Example below:

    sample

     

     

    The API URL has (myOrgId) which isnt valid in the request, so you may want to proof read your URL and make sure its fully substituted as well

  • Kwangsub.Ahn9052
    Kwangsub.Ahn9052 Posts: 9 🌱
    edited November 2022
    Options

    I am trying to call an API to upload a file.

    /d2l/api/le/1.22/[orgId]/dropbox/folders/[folderId]/submissions/mysubmissions/

     

    Could you give me any working example using above API? I've tried to fix but always it throws 500 error (or 400).

  • Kwangsub.Ahn9052
    Kwangsub.Ahn9052 Posts: 9 🌱
    edited November 2022
    Options

    I am curious about how to put multipart/mixed; boundary=xxBOUNDARYxx for type and body below.

    --xxBOUNDARYxx

    Content-Disposition: form-data; name=""; filename="file.txt"

    Content-Type: text/plain

     

    This is a sample text file with some text content.

    --xxBOUNDARYxx--

     

    This kind of information is used from the sample code from github link you gave me but There is no such place to put this information in API test tool

     

     

  • Jordan.Snider3520
    Jordan.Snider3520 Posts: 42
    edited November 2022
    Options
  • Kwangsub.Ahn9052
    Kwangsub.Ahn9052 Posts: 9 🌱
    edited November 2022
    Options

    Thanks, it helped.

     

    Just one thing about Content-Type, I needed to put "multipart/mixed;boundary=xxBOUNDARYxx" but there was no option for this in API tool so after I forced to change the text in select box option from browser, I was successfully able to get response.

  • Jordan.Snider3520
    Jordan.Snider3520 Posts: 42
    edited November 2022
    Options

    Awesome glad it worked for you! Please be sure to the comment that helped as "Best Answer" to help other devs find this answer easily in the future :)

  • vdizzle...423
    vdizzle...423 Posts: 3 🌱
    edited November 2022
    Options

    would really like to know where you were " forced to change the text in select box option from browser" is located at. I am having this exact same issue trying to upload a file. If anyone at d2l can help that would be great!