{"id":23138239,"url":"https://github.com/softlayer/.net-rest-tool","last_synced_at":"2025-08-17T11:32:52.010Z","repository":{"id":1011027,"uuid":"832155","full_name":"softlayer/.NET-REST-Tool","owner":"softlayer","description":"A handy .NET-based REST troubleshooting tool with C# and vb.NET source available.","archived":false,"fork":false,"pushed_at":"2011-05-27T19:22:59.000Z","size":272,"stargazers_count":14,"open_issues_count":0,"forks_count":11,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-05-09T17:09:57.176Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softlayer.png","metadata":{"files":{"readme":"README.textile","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.textile","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-08-11T21:59:01.000Z","updated_at":"2023-09-12T20:41:46.000Z","dependencies_parsed_at":"2022-07-06T01:31:16.325Z","dependency_job_id":null,"html_url":"https://github.com/softlayer/.NET-REST-Tool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2F.NET-REST-Tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2F.NET-REST-Tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2F.NET-REST-Tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2F.NET-REST-Tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softlayer","download_url":"https://codeload.github.com/softlayer/.NET-REST-Tool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230121666,"owners_count":18176477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T13:10:17.680Z","updated_at":"2024-12-17T13:10:17.867Z","avatar_url":"https://github.com/softlayer.png","language":"C#","readme":"h1. SoftLayer RESTful API Services and .NET\n\nh2. Introduction\n\nSoftLayer has recently exposed their API to the public.  What's more, we have introduced a RESTful interface to that API.  RESTful services are services that expose functionality via a REST (REpresntational State Transfer) software architecture.  REST is a client/server architecture in which the requests and responses are built around representations of resources.  While not limited to HTTP, HTTP lends itself quite well to this style of interaction between entities.  The SoftLayer RESTful service is just one more way we continue to give our customers unparalleled flexibility.\n\nSo how does it work?  We thought you'd never ask!  In its simplest incarnation there is a direct correlation between the service, method name, and response.  The SLDN wiki has a complete reference that does a great job explaining both the basic and advanced topics associated with consuming the SoftLayer API as a RESTful service.\n\n\"http://sldn.softlayer.com/wiki/index.php/REST\":http://sldn.softlayer.com/wiki/index.php/REST\n\nh2. .NET Examples\n\nThe REST examples we have compiled are very basic.  They are meant both to serve as a spring board for your own applications, as well as to serve as a sort of tool kit, while you are testing and developing.  While the example applications work reasonably well, they are lacking in polish and exception handling.  Please keep this in mind when creating your own real-world applications.  We made a decision to choose code clarity over robustness in these applications and as such they would require some honing before they could be deployed.\n\nh2. Requirements\n\nThe example projects have been written using the professional edition of Microsoft Visual Studio 2010.  Both C Sharp and Visual Basic project files are provided.  The samples require the 4.0 version of the .NET framework, and have been tested on a 32-bit Windows 7 desktop.  The test platform was running at 2.13Ghz and had 4GB of RAM installed.\n\nh2. Using the Sample Code\n\nWhen you first execute the application, you will see a large Windows form. (Figure 1)\n\n!http://sldn.softlayer.com/wiki/images/8/81/Rest-tool-readme-figure1.png!\nFigure 1\n\nThe first thing you will have to do is enter a username and an API Key.  You can retrieve both of these from the \"SoftLayer Management Portal\":https://manage.softlayer.com/.  The default URL for the SoftLayer RESTful service, as well as an end point to retrieve a list of recently closed tickets, has already been filled in for you.\n\nAfter you have entered a valid username and API key go ahead and click the \"HTTP Get\" button.  If you have closed any tickets on your account over the last three days, they will show up in the response window.  Otherwise, you will see an empty XML document.  (Figure 2)\n\n!http://sldn.softlayer.com/wiki/images/9/98/Rest-tool-readme-figure2.png!\nFigure 2\n\nNow go ahead and click on the radio button labeled \"Servers on Account\".  Did you see the end point change?  If not, click the \"Recently Closed Tickets\" radio button and try again.  The end point used to retrieve all the servers on the account is an example of an object mask.  When you click the \"Http Get\" button, the application should return a list of both hardware and virtual guests that belong to the account. (Figure 3)\n\n!http://sldn.softlayer.com/wiki/images/5/5c/Rest-tool-readme-figure3.png!\nFigure 3\n\nWhat if you only wanted to see the IDs for the servers?  Simply change the end point by clicking in the field and adding the qualifier \".id\" to both the hardware and virtual guest keys. (Figure 4)\n\n!http://sldn.softlayer.com/wiki/images/2/25/Rest-tool-readme-figure4.png!\nFigure 4\n\nAt this point, it should be obvious that you can type any end point you'd like to test into the field.  But you probably also noticed that only the \"Http Get\" button has been enabled.  That's because the calls we have been making don't require any POST variables.  They have been strictly object retrieval calls.  REST supports get, post, delete, and put requests.\n\nClick on the \"New Ticket\" radio button.  You'll see that the \"Post Vars\" field is populated and the \"Http Post\" button is enabled. (Figure 5)\n\n!http://sldn.softlayer.com/wiki/images/7/76/Rest-tool-readme-figure5.png!\nFigure 5\n\nAt this point if you simply hit the \"Http Post\" button you will get an error. (Figure 6)\n\n!http://sldn.softlayer.com/wiki/images/b/b3/Rest-tool-readme-figure6.png!\nFigure 6\n\nWhy you ask?  Because this call creates a new ticket and as such it requires a valid user ID and server ID.  If you scroll through the \"Post Vars\" you will see there are three tags all in caps: one that tells you to insert your user ID, one that tells you to insert your server ID, and one that says HARDWARE.  If you replace the first two parameters with valid IDs, and make sure that the last field says HARDWARE if the server ID you provided is a dedicated server, or VIRTUAL_GUEST, if the server ID you provided is a computing instance, you will find that hitting the \"Http Post\" button actually opens a standard support ticket on your account.\n\nYou can type any XML parameters into the \"Post Vars\" field you like.  For optional parameters the tag \u003citem /\u003e  equates to NULL.  Rudimentary XML parsing is done on the field when it loses focus.  So it should at least catch malformed XML.\n\nh2. The Source Code\n\nWhether using VB.NET or C#, the source code is fairly self explanatory.  The event handlers for the button clicks perform the network communications using the @HttpWebRequest@ object.  Authentication is performed by stuffing the username and api key into the header, after base64 encoding it.\n\nOne bit of confusion may be the reference to the @ServicePointManager@.  This just allows us to override any certificate issues with the API server while debugging.\n\nIn the case of an Http Get, the code simply loops on the input stream until it reaches the end, then the results are displayed in the response text window.  In the case of the Http Post, before reading we write the XML to the request stream.  This is in effect the body content of the HTML request.\n\nBesides the two handlers for the button clicks and the @FormatXml@/@JSON@ functions which does some very basic formatting on the results, the code is all very standard Windows UI.  Anyone reasonably familiar with .NET programming should be able to scroll through the example and quickly grasp how it all works.\n\nh2. Where to go From Here\n\nWhile this example was written to demonstrate SoftLayer’s RESTful services at a basic level, the freeform text boxes make it possible to create very complex request,  SoftLayer's RESTful services also support JSON input and output. SoftLayer’s REST interface supports object masks as well as pagination.  As mentioned previously the service also implements Http Put for editing existing records, and Http Delete for removing records.  If you have not yet done so, be sure to read the \"SLDN REST documentation\":http://sldn.softlayer.com/wiki/index.php/REST in its entirety.  Other resources include the \"SoftLayer forums\":http://forums.softlayer.com/ and our \"GitHub repository\":http://github.com/softlayer/.  You can also always \"e-mail us\":mailto:sldn@softlayer.com.\n\nh2. Author\n\nThis software is written by the SoftLayer Development Team \u003c\"sldn@softlayer.com\":mailto:sldn@softlayer.com\u003e.\n\nh2. Copyright\n\nThis software is Copyright (c) 2010 \"SoftLayer Technologies, Inc\":http://www.softlayer.com/. See the bundled LICENSE.textile file for more information.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftlayer%2F.net-rest-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftlayer%2F.net-rest-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftlayer%2F.net-rest-tool/lists"}