REST API calls through Pentaho Data Integration (Spoon) - rest

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.

Related

how/where to add token in http get request in Rest Debugger Delphi

web-service has token parameter. In swagger and postman I send get-request properly (status 200). In Poastman creating request is very easy because it has separate pages for parameters and headers.
As for Rest Debugger I couldn't create and sent right get-request( appears error 400).
I tried many ways but without success:
I write token in request parameter section of Rest Debugger as key-value pair like "token"= "abcd12345..."
or
I write base URL and resouce together in URL-field like:
https://testserver.com/currencies?token=abcd12345..... or
I write resource separately in resouce field of Rest Debugger and base -URL in URL-field
but in all cases server returns error 400:
"the token field is required".
screens of swagger, curl, postman and rest debugger.
We suppose that a better solution is to use Postman for this task, if it works as expected and is more user-friendly. But if it’s principal thing – you can do it in Rest Debugger.
Go to the “parameters” tab -> click the “Add” button -> change “Kind” field to “HEADER” -> “Name” field to ‘’token” -> “value” to your token value.
You can see that in Postman you use a header to send token value, but in Rest Debugger simple param – that’s why you get different results.
Try to define it as header.
Use Parameter section and use [HEADER] instead of [GET/POST]

Azure Data Factory - Web activity with header value containing comma failing

We are trying to ingest data from Amazon Selling Partner API. We currently have an azure function that signs our request and returns the header values. The authorization header contains commas in it and the comma causes the activity to fail on the client side.
Here is an exampleof the authorization header:
AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request,SignedHeaders=date;host;x-amz-content-sha256;x-amz-date;x-amz-storage-class,Signature=98ad721746da40c64f1a55b78f14c238d841ea1380cd77a1b5971af0ece108bd
To reproduce, create a new pipeline and add a web activity. Enter "http://www.google.com" for the url with the method GET. Add a header like above.
You should get the following error:
Error calling the endpoint 'http://www.google.com'. Response status code: 'NA - Unknown'. More details: Exception message: 'NA - Unknown [ClientSideException] The format of value 'AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request,SignedHeaders=date;host;x-amz-content-sha256;x-amz-date;x-amz-storage-class,Signature=98ad721746da40c64f1a55b78f14c238d841ea1380cd77a1b5971af0ece108bd' is invalid.'.
Request didn't reach the server from the client. This could happen because of an underlying issue such as network connectivity, a DNS failure, a server certificate validation or a timeout.
Any work arounds for this?
Thanks,
Scott
If you are using Authorization as a header to get data make sure to use bearer in front of the Token.
Authorization Bearer < Access Token >
I tried to reproduce the same in my environment and got below results:
Output:
For more information refer this SO thread .

Here API returns Unrecognized Kid Null error

This is my cURL request
curl https://geocode.search.hereapi.com/v1/geocode?q=5%20Rue%20Daunou%2C%2075000%20Paris%2C%20France -H "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXX"
This is the response
{"error":"Unauthorized","error_description":"Token Validation Failure - unrecognized kid null"}
I am not sure what is going on. I tried different access keys. I generated new ones. But keep getting the same error.
The "Access Key ID" is not quite the token you need to send in the Authorization header, which is why you get a "Token Validation Failure".
The "Access Key ID" is however one of the credential parameter that you need, in order to generate the OAuth tokens, the other parameter being the "Access Key Secret".
If you didn't save the Access Key Secret already, go to your HERE Account Project Management Space and make sure to download the credential file:
In the credential file, pay attention to the last three lines:
here.access.key.id = redacted
here.access.key.secret = redacted_redacted_redacted
here.token.endpoint.url = https://account.api.here.com/oauth2/token
Then, we can use Postman to generate the OAuth tokens:
Open Postman and create a new request.
Method POST, url: https://account.api.here.com/oauth2/token
Go to the Auth tab and select:
Type: OAuth 1.0
Add auth data to Request Headers (probably the default choice)
Signature Method: HMAC-SHA256
Consumer Key: put the here.access.key.id value
Consumer Secret: put the here.access.key.secret value
Go to the Body tab and select:
x-www-form-urlencoded
Key: grant_type, Value: client_credentials
Send the request. You should receive an access token. That one should work with your curl request.
Auth tab
Body tab
Note
For the record, the following, not using OAuth but an "API key" to be found under the REST section as well, also works:
curl https://geocode.search.hereapi.com/v1/geocode?apiKey=<REST-API-KEY>&q=5%20Rue%20Daunou%2C%2075000%20Paris%2C%20France
However the Geocode API Reference does not document the apiKey authentication, unlike other HERE API e.g. Routing, and I would not recommend it besides for occasional experiments with curl requests.
I found a very simple solution. I removed the Authorization header and added the "apiKey" query parameter to my URL.
For example:
https://revgeocode.search.hereapi.com/v1/revgeocode?48.2181679%2C16.3899064&lang=en-US&apiKey={TOKEN}

How to add Oauth Bearer token in QTP

I'm working on HP UFT Rest API Testing where i need to Pass "Authorization : Bearer " to perform or execute the Rest Service request then only my service will execute and displays the response.
Can any one give me the solutions,How to add Oauth Bearer token in QTP for Rest API Testing.
Please refere below link :
https://admhelp.microfocus.com/uft/en/14.03/UFT_Help/Content/User_Guide/task_API_coding_manipulate_WSC_properties.htm
There will be methods associated with the every block/methods , you can write C# code to append the string to the output of authorization operation and store in a global variable- that can be passed as a input to subsequent operation.
BeforeMethod , aftermethods are some of Event Handlers that are assosicated with each operation.

Swagger Inspector version of C# call failing when using token

I have the following code:
string tokenValue = "221e0a91-6530-4790-a969-d1da75b0afd2";
// Configure httpClient to use the above token.
httpClient.DefaultRequestHeaders.Add("token", tokenValue);
The subsequent calls (HEAD, POST, GET) all work fine.
When I try to do the same thing using Swagger Inspector, it fails. I am able to get a token using Swagger Inspector site, and I place the token into a HEAD call as follows:
But as I said, the call fails, with "Authorization has been denied for this request." message returned as an XML file.
I also tried the two other options available on the same page: Basic Authentication, and OAuth 2.0/JWT, all with HTTPS. They all fail.
How can I go about understanding why it's failing?
Also: Is what I am using above called "Bearer Authentication"?
I have below 2 things to mention from your screenshot:
Response for HEAD method never contains the response body, it always contains the response headers
for more details of HEAD: HEAD Request
But in your case response-body is also present (maybe of CML content type).
You should use OAuth 2.0/JWT option on the same page to pass the token along with your request.
To answer your question related to Bearer Authentication:
No, the one you are trying to use is not at all Bearer Authentication.
In your case, "token" will be considered as Custom/User HTTP Header.