Skip to main content
Community site session details

Community site session details

Session Id : W2o0MHm4XLMCAEoPjGLGiE
Power Automate - Connector Development
Unanswered

How to read query parameters using custom connector in C#

Like (0) ShareShare
ReportReport
Posted on 3 Apr 2024 18:39:55 by 4

I have created a custom connector defining the below query parameters. Now, I need to fetch query parameter values and then transform it before sending the request to third-party API. As you can see below, I have defined these parameters under Query section.

AAW23_0-1712168500773.png

 

Now, I have written the below code in c#, but I am not able to fetch parameter values from JSON object. Now, if I define these parameters in the body section then I am able to fetch it. See below.

 

 private async Task<HttpResponseMessage> TransformRequestAndResponse()
    {
        HttpResponseMessage response;
        var contentAsString = await this.Context.Request.Content.ReadAsStringAsync().ConfigureAwait(false);      
        var contentAsJson = JObject.Parse(contentAsString);        
 
        // Fetch parameter values from the request payload. Below code highlighted in red isn't fetching the parameter values since these values are part of Query parameters. 
        var formIdvalue = (string)contentAsJson["formID"];
        var workspaceIdvalue = (string)contentAsJson["workspaceID"];
        var projecttitlevalue = (string)contentAsJson["projectTitle"];
        var requesterIdvalue = (string)contentAsJson["requesterID"];
        var requesterNamevalue = (string)contentAsJson["requesterName"];
        
         this.Context.Request.Content = CreateJsonContent(contentAsJson.ToString());

        // Sending the connector API request
        response = await this.Context.SendAsync(this.Context.Request, this.CancellationToken).ConfigureAwait(continueOnCapturedContext: false);
        
       // Manipulate the response data before returning it
        var responseContentAsString = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
        var responseContentAsJson = JObject.Parse(responseContentAsString);
        response.Content = CreateJsonContent(responseContentAsJson.ToString());

        return response;
    }

 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Featured topics

Loading complete