1 Replies - 497 Views - Last Post: 13 May 2013 - 10:05 AM

#1 meksPH  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 03-May 13

how to bind a text box to skidrive API

Posted 13 May 2013 - 04:27 AM

I have a code which creates the new folder in Skydrive using it's api. Its actually working. But it always creates the folder with the same name. Because the name of the folder is hardcoded.

My question is how to bind a textBox to API call so it will pass the user indicated name of the folder to API

here is the code of creating a folder:
<script src="//js.live.net/v5.0/wl.js" type="text/javascript" language="javascript"></script>
  <script type="text/javascript" language="javascript">
      function createFolder_onclick() {
          WL.login({
              scope: "wl.skydrive_update"
          }).then(
          function (response) {
        WL.api({
            path: "me/skydrive",
            method: "POST",
            body: {
                "name": "This is a new folder",
                "description": "A new folder"
            }
        }).then(
            function (response) {
                document.getElementById("infoArea2").innerText =
                    "Created folder. Name: " + response.name + ", ID: " + response.id;
            },
            function (responseFailed) {
                document.getElementById("infoArea2").innerText =
                    "Error calling API: " + responseFailed.error.message;
            }
        );
    },
    function (responseFailed) {
        document.getElementById("infoArea2").innerText =
            "Error signing in: " + responseFailed.error_description;
    }
      );
      }
  </script>



Is This A Good Question/Topic? 0
  • +

Replies To: how to bind a text box to skidrive API

#2 laytonsdad  Icon User is online

  • Cheese and Sprinkles
  • member icon

Reputation: 440
  • View blog
  • Posts: 1,867
  • Joined: 30-April 10

Re: how to bind a text box to skidrive API

Posted 13 May 2013 - 10:05 AM

So I see this is the example from the docs.

You said it works to create a folder but you want to add a name via user input.

Create an text input that will contain the name input from the user.
<input id="folderName" type="text"/>


Then at the begining of your createFolder_onclick() function create a variable to hold it.
var folderName = document.getElementById("folderName").value


Then add that variable to your api call.
WL.api({
            path: "me/skydrive",
            method: "POST",
            body: {
                "name": folderName, // here I added the variable name that holds the text from the input.
                "description": "A new folder"
            }


I hope this helps.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1