Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
How to pass query parameters in rest api?

I have passed body parameters include method in single object to call api but iam unable to pass query parameters in the object.

code is

let fkPostPayload = {
        httpMethod: "POST",
        path: "/event",
        body: {
            "payload": {
                "application": {
                    "id": 11870117004,
                    "candidate": {
                        "id": 10921993004,
                        "first_name": "011200aaa0Test01FF",
                        "last_name": "01111200aa0Test01FF",
                        "title": null,
                        "is_private": true,
                        "can_email": true,
                        "external_id": null,
                        "phone_numbers": [],
                        "email_addresses": [
                            {
                                "value": "02000111aaa111Test01FF@test.com",
                                "type": "personal"
                            }
                        ],
                    },
                }
            }
        },
        queryParam:{ "clientId":70, "countryCode":"BRA","partner":"AA-GMS" }
    }

i have passed the payload in api call, able to get body parameters value but unable to get queryparam values. suggest the better solution.

when i tried to get query params value using req.query its return empty object.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try to pass parameters in the path

import map from 'lodash/map'

const httpBuildQuery = function (url, queryParams) {
  const queryString = map(
    queryParams,
    function (val, key) {
      return encodeURIComponent(key) + '=' + encodeURIComponent(val)
    }
  ).join('&')

  if (queryString) {
    const separator = !url.includes('?')
      ? '?'
      : '&'

    return url + separator + queryString
  } else {
    return url
  }
}

let fkPostPayload = {
  httpMethod: "POST",
  path: httpBuildQuery("/event", { "clientId":70, "countryCode":"BRA","partner":"AA-GMS" }),
  body: {
      "payload": {
          "application": {
              "id": 11870117004,
              "candidate": {
                  "id": 10921993004,
                  "first_name": "011200aaa0Test01FF",
                  "last_name": "01111200aa0Test01FF",
                  "title": null,
                  "is_private": true,
                  "can_email": true,
                  "external_id": null,
                  "phone_numbers": [],
                  "email_addresses": [
                      {
                          "value": "02000111aaa111Test01FF@test.com",
                          "type": "personal"
                      }
                  ],
              },
          }
      }
  }
}
about 4 years ago · Juan Pablo Isaza Report

0

otherwise simply we can pass using

queryStringParameters:{clientId:"70"}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!