0
votes

I am using API connect to interface with one of the databases I work with rather than directly sending the query through code to the Rest API (which is much more efficient for what I am doing). But alas, not allowed.

Anyway, here is my issue:

 BASE PATH:   

 https://api.com/apim

Everything is appended to the end of this example URL such that:

 API PATH:

 https://api.com/apim/myapi/{some value}

 Values: '\Project\ProjectInfo\'

The URL is attempting to accept this as part of the URL rather than as a string I am trying to send to the defined query in the API itself. This is throwing us some HTTP errors and I am not exactly sure how we can get around this short of encapsulating the value into something. Trouble is I am not sure if API connect can even do this. Unfortunately the query in question that requires the File Path type value cannot be changed.

Any of you fine lads have more experience with API connect than my extremely limited knowledge of it at present?

2

2 Answers

0
votes

you can try to send the extra path in a query string format, asociated with a variable, and encoding de value for a request html.

 \Project\ProjectInfo\ => %5CProject%5CProjectInfo%5C

Then you asign you encoded value in a query string variable:

https://api.com/apim/myapi/variable=%5CProject%5CProjectInfo%5C

Then you can use a "gatwwayScript" politic to decode the value:

https://www.ibm.com/support/knowledgecenter/en/SS9H2Y_7.7.0/com.ibm.dp.doc/querystring_js.html

0
votes

1: From your example it appears that you are trying to use path parameters to determine the request for your back end. If this is intended then you would just need to reference that variable in your invoke/proxy policy.

IE: https://api.com/apim/myapi/{someValue} Answer to question on how to use path variables: Is it possible to use wildcards in API paths in IBM API Connect

Reference variable in the invoke/proxy policy: - invoke: target-url: "https://mybackend.com$(someValue)"

2: you could split up the segments of the path you want into several variables and use a policy, IE: gatewayscript or map, to build a url variable referenced by the invoke/proxy policy for the call to the DB.

IE: https://api.com/apim/myapi/{someProject}/{someProjectInfo}

3: you can have it as a required query parameter in your api path and reference that variable in your invoke/proxy policy. This would allow for the entire backend request to be dynamic so you do not have to republish anytime the backend address changes

IE: https://api.com/apim/myapi/dbCall?dbUrl="https://somebackend.com/project/projectinfo"

Reference in invoke: - invoke: target-url: "$(dbUrl)"

Similarly you could require it be in the request headers or body.