cancel
Showing results for 
Search instead for 
Did you mean: 

API consume in SAP cloud platform integration services

hsonnenahalli
Contributor
0 Kudos

Experts-

I have a question regarding consuming API into SAP cloud platform integration services to build iflows. I have the information of the API and API key for a user. I am not seeing any option in integration services to call the API directly using the API key like we do in POSTMAN client. I know API management is an option in SAP cloud platform but am not sure how to leverage the same. I know if we can create OData, REST and SOAP services the same can be consumed using API management but not sure the other way. Please, it would be appreciated if anyone can share the experience or taught on this issue.

Please let me know.

Regards

HS

Accepted Solutions (1)

Accepted Solutions (1)

MortenWittrock
Active Contributor

Hi Hari

I'm assuming you need to pass your API key along to the service in either a query parameter or a header, and both are definitely doable in Cloud Integration.

Regards,

Morten

hsonnenahalli
Contributor
0 Kudos

Thanks for the quick response. Do you have any documents or input to achieve this requirement? I know Groovy script is an option but it would be too technical for my customer. Is there any other way which will be simpler.

Please let me know.

Regards

HS

MortenWittrock
Active Contributor
0 Kudos

Hi Hari

A header can be added with a Content Modifier step. A query parameter can be added directly to the configuration of the service's receiver channel. If you have the API key in a property called MyAPIKey, you can add it to a query parameter called apikey as follows:

apikey=${property.MyAPIKey}

Regards,

Morten

hsonnenahalli
Contributor
0 Kudos

I apologize for the delay. I wanted to provide you with a real example.I have following URL. In this request, we need to send the DSN which is system and also the key. If am using the content modifier step. I will have the following settings.

https://app.ticketmaster.com/sth-customer/ticketing_services.aspx?dsn=apigee≈ikey=c4QMMWnX7WbQrXVtlR...

message.Header = Content-Type,application/json

message.Header = Accept,application/json

message. Property = apikey,c4QMMWnX7WbQrXVtlRgldWJBF0fKVqr3

After this am not sure what will be my URL and Query if am doing POST and GET. Please it will be appreciated if you can help me with this issue.

Thanks

HS





MortenWittrock
Active Contributor
0 Kudos

Hi Hari

Assuming you have the API key in a property called apikey, your HTTP channel would look like this:

The method is POST, since you are passing a JSON object to the service.

Regards,

Morten

hsonnenahalli
Contributor
0 Kudos

Thanks for the quick reply. I need to send request data to the service which can be sent in content modifier is that correct? The way the service works is you need to send a request data to get the response. I did following configuration in the content modifier. I am passing following query In content modifier.

Please let me know.

Thanks

HS

{"header":{"ver":1,"src_sys_type":2,"src_sys_name":"testing","archtics_version":"V999"},"command1":{"cmd":"ats_ext_test_polling","uid":"user99","dsn":"apigee"}}

hsonnenahalli
Contributor
0 Kudos

Forgot to attach couple more screenshots:)

MortenWittrock
Active Contributor
0 Kudos

Yes, the request body (i.e. the JSON data that you send to the service) can be added in a Content Modifier.

Regards,

Morten

hsonnenahalli
Contributor
0 Kudos

Does my other configuration looks correct? like header and property which I have set in content modifier and my HTTP receiver channel configuration?

Please let me know.

Thanks

HS

MortenWittrock
Active Contributor
0 Kudos

Yes, looks good.

Regards,

Morten

MortenWittrock
Active Contributor
0 Kudos

Also, I noticed that the API has a ping command, so you can go ahead and test your setup with that.

Regards,

Morten

hsonnenahalli
Contributor
0 Kudos

I am receiving 401 error. It is saying invalid API key but the same is working fine using POSTMAN. Please let me know if you have any ideas to resolve this error.

I do really appreciate your help.

Regards

HS

Duration 444 ms Error org.apache.camel.component.ahc.AhcOperationFailedException: HTTP operation failed invoking https://app.ticketmaster.com/sth-customer/ticketing_services.aspx?dsn=apigee≈ikey= with statusCode: 401KeyValueDescriptionProcessing exchange ID-vsa3471622-53088-1523743031491-151-2 in ahc:https://app.ticketmaster.com/sth-customer/ticketing_services.aspx?clientConfig=#clientConfig_Receiver_HTTP&binding=#binding_Receiver_HTTP&clientConfig.requestTimeoutInMs=60000&clientConfig.idleConnectionInPoolTimeoutInMs=60000&clientConfig.idleConnectionTimeoutInMs=60000&clientConfig.connectTimeout=10000RealDestinationUrlhttps://app.ticketmaster.com/sth-customer/ticketing_services.aspx?dsn=apigee≈ikey=ResponseBody{"fault":{"faultstring":"Invalid ApiKey","detail":{"errorcode":"oauth.v2.InvalidApiKey"}}}HTTPRequestHeadersContent-Type: application/json SAP_MessageProcessingLogID: AFrhCYUs1TyThERDDmnQvPngne3a SAP_MplCorrelationId: AFrhCYXE_YcGc5dJv2ifP_BxxE6z SAP_PregeneratedMplId: AFrhCYXqV0qLzdqMsaMVbj5oMMOHHTTPResponseHeadersConnection: keep-alive Content-Length: 90 Content-Type: application/json Date: Wed, 25 Apr 2018 23:04:37 GMTHTTPStatusCode
MortenWittrock
Active Contributor
0 Kudos

Ah, hang on, your apikey property is set to type "Property", but should in fact be "Constant". You are specifying a constant value, not taking the value from another property.

Regards,

Morten

hsonnenahalli
Contributor
0 Kudos

I tried the ping but still the same result. Please let me know.

Thanks

HS

Duration 448 ms Error org.apache.camel.component.ahc.AhcOperationFailedException: HTTP operation failed invoking https://app.ticketmaster.com/sth-customer/ticketing_services.aspx?dsn=apigee≈ikey= with statusCode: 401 KeyValueDescriptionProcessing exchange ID-vsa3471622-53088-1523743031491-152-2 in ahc:https://app.ticketmaster.com/sth-customer/ticketing_services.aspx?clientConfig=#clientConfig_Receiver_HTTP&binding=#binding_Receiver_HTTP&clientConfig.requestTimeoutInMs=60000&clientConfig.idleConnectionInPoolTimeoutInMs=60000&clientConfig.idleConnectionTimeoutInMs=60000&clientConfig.connectTimeout=10000RealDestinationUrlhttps://app.ticketmaster.com/sth-customer/ticketing_services.aspx?dsn=apigee≈ikey=ResponseBody{"fault":{"faultstring":"Invalid ApiKey","detail":{"errorcode":"oauth.v2.InvalidApiKey"}}}HTTPRequestHeadersContent-Type: application/json SAP_MessageProcessingLogID: AFrhDSoAivsm5MoQFHsvbt44UxkD SAP_MplCorrelationId: AFrhDSryu2iXm8KkFqmN0wyPVYys SAP_PregeneratedMplId: AFrhDSoSTXKEZ8EQuAjrbGnDvnGsHTTPResponseHeadersConnection: keep-alive Content-Length: 90 Content-Type: application/json Date: Wed, 25 Apr 2018 23:20:11 GMTHTTPStatusCode
MortenWittrock
Active Contributor
0 Kudos

See above. Your apikey property is not correctly defined.

Regards,

Morten

hsonnenahalli
Contributor
0 Kudos

Thanks a lot for the help and it is working now:)

Regards

HS

Answers (0)