Touch Develop retirement postponed until June 22, 2019. Sign-in and access to cloud assets to be removed on May 23, 2018.Learn More..

web requests

The web service provides helper to perform common web queries or you can have full control over the HTTP request using Web Request.

download and uploads

The following actions implement common download and upload operations. Downloads are implemented as HTTP GET; uploads as HTTP POST.
  • download text
var text := web → download(url)
var js := web → download json(url)
var pic := web → download picture(url)
  • upload text using a POST
var response content := web → upload(url, content)
These action return invalid if failed. For more information about the error, use the web request below.

HTTP web requests

In many case, you will need to have a fine control over request content, headers and the response as well. The web→create request action returns a HTTP Web Request object that gives you full control.
  • create a request to url
var request := web → create request(url)
  • setting headers
request → set header("Authorization", "Bearer ...")

synchronous requests

The send action send the request and blocks until the Web Response has been returned.
var response := request → send
The response contains the status code, headers and content.
var status code := response → status code
js := response → content as json

asynchronous requests

The send async action sends the request and continues without blocking. Upon completion, the on reponse received event is raised.
  • attach a handler to the on response received event
request → on response received(handler)
where handler(response : Web Response) is
response → post to wall
  • send the request async
request → send async


Web requests support Web API using api keys and OAuth 2.0.


You can use Json Builder to craft a JSON payload.
var jsb := web → create json builder
jsb → set string("name", "value")
Then use set content as json to set the JSON as the content of the request. The Content-Type header is automatically set.
request → set content as json(jsb → to json)


Use web→xml to parse XML markup and set content as xml to attach it to the request.
var xml := web → xml("</some_xml>")
request → set content as xml(xml)


You can use Form Builder to create a HTML forms request.
var form := web → create form builder
form → add string("name", "value")
Then use set content as form to attach it to the request.
request → set content as form(form)

running ino problems? web requests, "same origin policy" and CORS

If you are using the TouchDevelop Web App to perform web requests, you might run into seemingly strange problems where your requests do not get fulfilled as you would expect. The underlying problem might be related to the "same origin policy" of your browser. The mechanism to mitigate this problem is called "CORS - Cross-origin resource sharing". Learn more about CORS and how to implement it..