Request method 400(Bad request) in iparams.html

Hi Team,

I was making API call by using the request method in the settings page.

In local, it was working while testing,

Installed as the custom application, it was throwing 400 bad request error

Thanks in advance.

Hey @balanagendra,
it is also supported in custom iparams page with the domain and API key passed with context.

Can you share the request template? And the request.invokeTemplate() from iparams.js file.

Triggering SMI Function:

client.request
				.invoke("validateTrustpilot", {
					trustpilotBusinessName: trustpilotBusinessName
				})
				.then(
					function (trustpilot) {
						trustpilotBusinessUnitId = trustpilot.response.response[0]
					},
					function (err) {
						console.error(err)
					}
				)
		})

manifest.json :

"functions": {
        "validateTrustpilot": {
          "timeout": 10
        }
      },

In the SMI function this was the code:

const onValidateTP = async (payload) => {
	try {
		const { trustpilotBusinessName } = payload
		console.log("trustpilotBusinessName >> ", trustpilotBusinessName)

		const businessIdReq = await tpServices.getBusinessId(trustpilotBusinessName)

		const businessIdResp = JSON.parse(businessIdReq["response"])

		const businessId = businessIdResp["id"]
		console.log("businessId >> ", businessId)

		const businessInfoReq = await tpServices.getBusinessInfo(businessId)
		console.log("businessInfoReq >> ", businessInfoReq)

		renderData(null, { response: [businessId, businessInfoReq["response"]] })
	} catch (error) {
		console.log(`Error onValidateTP--->`, JSON.stringify(error))

		renderData({ status: error.status, response: error.response })
	}
}

request.json

"getBusinessId": {
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host": "api.trustpilot.com",
      "path": "/v1/business-units/find?name=<%= context.businessName %>",
      "headers": {
        "apikey": "8x33hmuxWr0lVTEXFWKGrmYs5sccIPM",
        "Content-Type": "application/x-s-form-urlencoded"
      }
    }
  },
  "getBusinessInfo": {
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host": "api.trustpilot.com",
      "path": "/v1/business-units/<%= context.businessId %>/profileinfo",
      "headers": {
        "apikey": "8x33hmuxWr0lVTEXFWKGrmYs5sccIPM",
        "Content-Type": "application/x-s-form-urlencoded"
      }
    }
  },

Hello Team,

any idea?