public override async Task ExecuteAsync()

in certified-connectors/Spring Global/script.csx [3:47]


    public override async Task<HttpResponseMessage> ExecuteAsync()
    {
        // Use the context to forward/send an HTTP request. Turn of caching
        var cacheControlHeader = new CacheControlHeaderValue(){NoStore=true, NoCache=true};
        this.Context.Request.Headers.CacheControl = cacheControlHeader;
        HttpResponseMessage response = await this.Context.SendAsync(this.Context.Request, this.CancellationToken).ConfigureAwait(continueOnCapturedContext: false);
                
        string responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(continueOnCapturedContext: false);

        try 
        {
            JObject surveyJson;
            string newResponceContent = responseString;
            bool contentChanged = false;

            if (this.Context.OperationId == "GetSurveyPublicationSchema")
            {
                var arrayResponse = JArray.Parse(responseString);
                surveyJson = arrayResponse.First as JObject;
                newResponceContent = this.GetSurveySchema(surveyJson);
                contentChanged = true;
            }
            else if (this.Context.OperationId == "GetExecutionById")
            {
                newResponceContent = this.GetSurveyData(responseString);
                contentChanged = true;
            }
            else 
            { 
                //Don`t do any thing for other operations
            }

            if (contentChanged)
            {
                response.Content = CreateJsonContent(newResponceContent);
                response.StatusCode = HttpStatusCode.OK;
            }
        }
        catch
        {
            //Don`t to transformation
        }

        return response;
    }