Skip to Content
0

API consume in SAP cloud platform integration services

Apr 10 at 10:16 PM

130

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Morten Wittrock
Apr 11 at 09:26 AM
1

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

Show 15 Share
10 |10000 characters needed characters left characters exceeded

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

0

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

0

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=c4QMMWnX7WbQrXVtlRgldWJBF0fKVqr3

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





0

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

connection.png (13.5 kB)
0

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"}}

tm1.png (28.9 kB)
tm2.png (35.3 kB)
0

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

Regards,

Morten

0

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

0

Yes, looks good.

Regards,

Morten

0

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

Regards,

Morten

0

Forgot to attach couple more screenshots:)

tm3.png (57.5 kB)
tm4.png (56.8 kB)
0

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
0

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

0

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
0

See above. Your apikey property is not correctly defined.

Regards,

Morten

0

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

Regards

HS

0