How to pass key value parameters in ADF web activity when Content-Type is multipart/form-data - azure-data-factory

I have a use case where we must pass username, password, grant_type, client_id, and client_secret via form-data in Azure Data Factory Web Activity.
Concatenating keys and values in the request body returns the below error. I am using the POST method and below is the header information.

Use post method in your web activity and provide your credentials under body.
grant_type=client_credentials&client_id={your client id}&client_secret={ client secret}&scope=API

Related

REST API calls through Pentaho Data Integration (Spoon)

Hello Pentaho Experts,
I am attempting to make a REST API call through REST Client in Pentaho. I have a Api key for authentication. I tried it in Postman, and it works perfectly fine, but Pentaho throws 403 status code. Below is the postman screenshot:
My Pentaho transformation contains two steps. I am passing URL through "Generate Rows" step and then adding Key and Value in the Header:
Generate Rows:
Rest Client (General):
Rest Client (Header):
Any idea what I might be missing here? Expected output is JSON.
I can't speak to the use of passing key/value in Header for authentication, but what has worked for me is to use the Authentication tab to input my credentials or passing an Authentication header with a bearer token.
Authentication Tab:
I use this method to generate and return a bearer token from the API. The token is then used as the authentication method in subsequent steps. The "body" includes the scope (i.e.: "reports:read") and grant type ("client_credentials"). The "header" contains the value "application/x-www-form-urlencoded".
Authentication Header:
Once a token has been returned from the API, this can be provided in an "authorization" header. Prepend "bearer" to the token value and pass this in the header tab.
I would also recommend looking at the Headers being passed in Postman to ensure you are not missing anything else that might be happening in your call.

How to use one REST API RESPONSE property, and use it in another REST API header property

I would like to know how to property transfer from one REST API to another REST API?
I worked on the property transfer with the JSON format, but I need to know how to transfer the one REST API response property and use it in the header?
let me explain this using the below scenario:
Admin get the User object by API
Save apiKey from the user object
Call the action on user behalf(By set Authorization Header to Basic with the user apiKey)
To accomplish these steps in soapUI You have to:
Define apiKey in Custom Properties in TestCase
Call resource that returns a User object
Save apiKey property to TestCase.apiKey via property transfer or Groovy Step
Reuse TestCase.apiKey in your nest REST Request step by expanding it via Basic ${=(testCase.getPropertyValue("apiKey")+":").bytes.encodeBase64()}
Hope that helps

How to convert api body x-www-form-urlencoded to raw plain/text

I'm setting up oAuth generation in new testing software, Tosca. Tosca can only handle API calls with raw body types. I need to convert below x-www-form-urlencoded payload to plain/text. The request is denied with "developerMessage": "The authentication service denied the request".
I have tried changing all of the ":"'s to "=" and all linebreaks to "&." Which has worked for converting other x-www-form-urlencoded payloads to plain/text. I have removed our client_id and client_secret and added them to basic auth. I have removed any and all special characters and spaces from the body and still getting error.
scope:openid
realm:employer
auth_method:cleartrust
auth_id_user_token:A+B/C/D==
nonce:cd
identity_method:air
response_type:id_token token
grant_type:password
which I changed to
scope=openid&realm=employer&auth_method=cleartrust&auth_id_user_token=A+B/C/D==&nonce=cd&identity_method=air&response_type=id_token token&grant_type=password
The plain/text api call should get a successful response and bring back oAuth token.
Full disclosure: I work for Tricentis in the Support Department.
Tosca's API Engine can also handle url-encoded payloads. See this manual page for an example screenshot: https://support.tricentis.com/community/manuals_detail.do?lang=en&version=12.3.0&url=engines_3.0/api/api_create_url-encoded.htm
Additionally, please follow these steps:
In the Technical View tab, open the Headers pane on the right-hand side. There enter a Content-Type header param with value application/x-www-form-urlencoded.
In the Auth tab, select Basic Auth as the method and use the client_id as the username and the client_secret as the password. Tick the checkbox Pre-authenticate.
In the Payload tab, you can enter the url-encoded payload required by your web service. Since you use grant_type = password, the payload has to include at least the string grant_type=password&username=someUsername&password=somePassword

keycloak client protocol mapper (script mapper) to add request header into token

When I'm requesting a token from keycloak I want a specific header value (or extra form data) that was supplied in the request to be put in the JWT payload of the generated token. I've tried using a Script Mapper to get access to header values but I can't see how to get access to header values or data in the form data sent in any of the available script variables: user, realm, userSession, keyclockSession.
You can get access to request headers using keycloakSession object, something like
keycloakSession.getContext().getRequestHeaders().getRequestHeader("User-Agent")
If you check the code for DefaultEvaluationContext class, that is how they add the User-Agent header.

How do I send REST request with the oauth parameters added in the URI (as input parameters)

I have a specificaiton for a project that accesses a third party service -RESTfully and requires oAuth authentication. [It accepts only GET method, and no access token is required since I will be trying to access the protected resources using consumer key and consumer secret values along with the oauth parameters.]
I am using SoapUI-Pro 4.6.1 and tried sending a GET request with oauth parameters as authorization header using signpost method, but my project accepts only when the oauth parameters are sent in the URL.
So, when I generate oauth signature, nonce and timestamp values manually using this link- http://oauth.googlecode.com/svn/code/javascript/example/signature.html and update it in my request URL, it is working fine.
Sample URL: http://sample.com/content/?oauth_consumer_key=abc&oauth_nonce=FUINSzmeoDh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1384436218&oauth_version=1.0&oauth_signature=ISAsa2LJt3tVhgCnbL/GQszcZbc=
Instead of this manual step, is there a way to generate oauth_signature, oauth_timestamp & oauth_nonce values automatically and then use it in the request URI as an input parameter?
Thanks in advance!
In the version SoapUI Version 5.0.0 and above, you have an option to add query parameters.
On clicking the text box on parameters, we get a window with options to add parameters. Refer to the image.