web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to read query para...
Power Automate
Unanswered

How to read query parameters using custom connector in C#

(0) ShareShare
ReportReport
Posted on 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;
    }

 

Categories:
I have the same question (3)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard