on 04-08-2020 12:04 PM
Hello SAP community,
I have a question to submit.
We are using CAP to reach an API from ApiManagement hosted on Neo.
Our model is defined in package.json as follow"cds":{
"requires : {
"orders": {
"kind": "odata",
"model": "srv/external/OrdersMetadata.json",
"credentials": {
"APIKey": <API_KEY> <--- we tried here
"requestTimeout": 10000,
"destination": "dest_orders"
},
"pool": {
"min": 1,
"max": 10
}
}
}
}
We tried while working locally for now to provide the credentials (APIKey) in destination defined in a default-env.jsonfile
{
"name": "dest_orders",
"url": "https://<API_MANAGEMENT_DEST>/v0/orderTracking",
"headers": {
"APIKey": <API_KEY> <--- and we tried here
}
}
but so far we are getting a 401 unauthorized and this error :
{ fault:
{
faultstring: 'Failed to resolve API Key variable request.header.APIKey',
detail: { errorcode: 'steps.oauth.v2.FailedToResolveAPIKey' }
}
}
So our guess is that APIKey is not forwarded with the request but we cannot find how to send the APIKey with the request.
Hi,
setting headers is supported with the next release (approximately end of August). Please check the documentation here:
https://github.wdf.sap.corp/pages/cap/node.js/api#srv-emit
const tx = service.transaction()
const resultUsingHeaders = await tx.emit({ query: SELECT.from('Entity'), headers: { header1: 'content' } })
Best regards
Samuel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Samuel,
please be aware that this is an external forum and the external link is:
https://cap.cloud.sap/docs/node.js/api#srv-emit
Best regards
Gregor
Hi,
thanks for reporting this gap - indeed, we currently don't offer a possibility to set headers in the http calls to a rest API. We are in discussion on how to extend our API accordingly. We will of course keep you updated here (but I cannot give a timeline yet, sorry...).
Best regards,
Heiko
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Heiko, iinside , dj.adams , mariusobert ,
So if we have to connect to external services like SuccessFactors from a CAP (SAP Cloud Application Model) nodejs project, how do we proceed? Can you please advise ? If you have any blogs, can you please share? The document at https://cap.cloud.sap/docs/guides/consuming-services#for-http-based-consumption is very vague.
Thanks and Regards,
Harish
Hi Harish,
as this question was specifically about the use of the api.sap.com APIKey together with CAP please post your question as a new topic.
Best regards
Gregor
User | Count |
---|---|
75 | |
10 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.