
Hello!
I'm building a logic app custom connector in Azure for my APIs.
the API use `application/x-www-form-urlencoded ` as a content-type, basically i want my custom connector to perform this:
curl "https://test.api.xxxx.com/xxxx/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}"so my swagger v2.0 looks like below, as advised from another post https://powerusers.microsoft.com/t5/Connector-Development/How-to-send-x-www-form-urlencoded-body/m-p/2178579#M2358
swagger: '2.0'
info:
version: 1.0.0
title: xxxxx
description: xxxxx
host: test.api.xxxx.com
basePath: /
schemes:
- https
produces:
- application/json
paths:
/xxxx/token:
post:
summary: Access Granted Client Credentials
description: ''
operationId: Oauth2Token
deprecated: false
consumes:
- application/x-www-form-urlencoded
parameters:
- name: Content-Type
in: header
required: true
type: string
description: ''
default: application/x-www-form-urlencoded
- name: grant_type
in: formData
required: true
type: string
description: ''
- name: client_id
in: formData
required: true
type: string
description: ''
- name: client_secret
in: formData
required: true
type: string
description: ''
if i use swagger Editor to try, and it successfully works (i can authenticate).
but once i saved my connector and try in a test logic app, I got error from my API (meaning at least the API went through) `Mandatory grant_type form parameter missing`. this error is coming when the grant_type is not properly passed. so i have checked my input raw in logic app and looks like this :
grant_type as client_credentials is there as a form-data, header is there `application/x-www-form-urlencoded`. I would like to check the real request that this logic app has sent but it looks like i can't check the log. I believe that logic app is override the header or putting the parameter not encoded, or put them somewhere else. (i don't know, there is no log!)
I have even tried to change my swagger, from `formData` to `query`, but it doesn't work.
I have tried to create a maunal HTTP request in a logic app to perform what i want to do with my custom connector, and it perfectly works well. and the body in input raw file looks like this :
My questions are :
- Is there any way that i can check the log to check how the request looks like?
- how to make body correctly built as below (or same result as manual HTTP)
"grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}"- How can I properly send the application/x-www-form-urlencoded request? i know that i can perform this by modifying my flow, but my goal is to create a custom connector to do the job for my API users.
- can anyone have same issue?
Hello,
To resolve the issue you're facing with the "x-www-form-urlencoded" body format, I recommend following these steps:
Start by referring to the provided document, "Monitor Diagnostic Data In Azure Logic Apps." This document will guide you on how to create logs for your Azure Logic App.
Review and correct the "x-www-form-urlencoded" body format. As mentioned, the URL-encoded parameters should be separated by ampersands (&), and each parameter should consist of a key-value pair separated by an equals sign (=). In your case, the corrected format would be: "grant_type=client_credentials&client_id=<actual_client_id>&client_secret=<actual_client_secret>".
Ensure that the corrected URL-encoded body structure is properly used in your Custom Connector. Verify that all the required parameters are included and in the correct format.
By following these steps, you should be able to address the issue you're experiencing with the application/x-www-form-urlencoded request format. If you encounter any further difficulties, please don't hesitate to ask for additional assistance.
I hope this solution helps resolve your issue.