-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathScript.csx
More file actions
24 lines (20 loc) · 1.09 KB
/
Copy pathScript.csx
File metadata and controls
24 lines (20 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System.Threading.Tasks;
using System.Net.Http;
using Newtonsoft.Json.Linq;
public class Script : ScriptBase
{
public override async Task<HttpResponseMessage> ExecuteAsync()
{
// Manipulate the request data as applicable before setting it back
var requestContentAsString = await this.Context.Request.Content.ReadAsStringAsync().ConfigureAwait(false);
var requestContentAsJson = JObject.Parse(requestContentAsString);
this.Context.Request.Content = CreateJsonContent(requestContentAsJson.ToString());
// Make the actual API request
var response = await this.Context.SendAsync(this.Context.Request, this.CancellationToken).ConfigureAwait(continueOnCapturedContext: false);
// Manipulate the response data as applicable before returning it
var responseContentAsString = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var responseContentAsJson = JObject.Parse(responseContentAsString);
response.Content = CreateJsonContent(responseContentAsJson.ToString());
return response;
}
}