Fetching all the values stored in Cache or Map without passing key as reference

Not applicable

I want to fetch all the values I have stored in a Map using Management UI APIs as given in "Get KeyValue Map in an environment".

Issue 1:Accessing in API Proxy using ServiceCallout

So,I framed the url as "https://api.enterprise.apigee.com/v1/organizations...<OrganisationName>/environments/test/keyvaluemaps/<Map_Name>

And used it in ServiceCallOut policy in my API Proxy.I have also included Basic Authentication Policy before ServiceCallOut.But its throwing below error in APIProxy,

"Execution of ServiceCallout Service-Callout-1 failed. Reason: ResponseCode 401 is treated as error

tried using Service callout to my Map which I created in KeyValue Operation Policy"

Issue 2 : Accessing in UI http://apigee.com/docs/management/apis/get/organiz...

I tried creating a KeyValue Map using API http://apigee.com/docs/management/apis/post/organi... and tried to use Get API.That is working fine if both creation and fetch done through APIs.

But when I create a Map in KeyValueMap policy and try to get the value through API,its throwing me

HTTP/1.1 404 Not Found

{ "code": "keyvaluemap.service.keyvaluemap_doesnt_exist", "message": "KeyValueMap MyCollectionMap does not exist", "contexts": [] }

So,I am getting two different types of errors when accessing in two ways.Please post me what is the solution to fetch all the values in a Map using API Proxy.

Solved Solved
0 5 365
1 ACCEPTED SOLUTION

Not applicable

@neil.munro

Thanks for your response....

I have deployed in test environment only.And I am able to fetch all the values in Map now using https://api.enterprise.apigee.com/v1/organizations...>/environments/test/keyvaluemaps/MyCollectionMap

Earlier for the same collection it wasn't working.Strangely its started working now when I try this url.

But when I am using Service callout,its still throwing error as,

{ "fault": { "faultstring": "Execution of ServiceCallout Service-Callout-1 failed. Reason: ResponseCode 401 is treated as error", "detail": { "errorcode": "steps.servicecallout.ExecutionFailed" } } }

So,I am still digging the issue....If you are aware of the solution,please let me know.

View solution in original post

5 REPLIES 5

Not applicable

Hi @RadhamaniRamadoss

If you created the KVM and its entries using the links to the docs you provided above, they default to using your dev environment.

I think you may be attempting to call the proxy that's deployed to your test environment (but the KVM is in dev)

You hint at this here

So,I framed the url as "https://api.enterprise.apigee.com/v1/organizations...<OrganisationName>/environments/test/keyvaluemaps/<Map_Name>

Try creating the KVM in the test environment or deploy the proxy to the dev environment (if it's not already) and call that proxy.

Neil

Not applicable

I should have added: although I quoted your callout policy description, I recreated the behaviour using the KVM policy

Not applicable

@neil.munro

Thanks for your response....

I have deployed in test environment only.And I am able to fetch all the values in Map now using https://api.enterprise.apigee.com/v1/organizations...>/environments/test/keyvaluemaps/MyCollectionMap

Earlier for the same collection it wasn't working.Strangely its started working now when I try this url.

But when I am using Service callout,its still throwing error as,

{ "fault": { "faultstring": "Execution of ServiceCallout Service-Callout-1 failed. Reason: ResponseCode 401 is treated as error", "detail": { "errorcode": "steps.servicecallout.ExecutionFailed" } } }

So,I am still digging the issue....If you are aware of the solution,please let me know.

And HTTP 401 is Unauthorised Error.I am already using Basic Authentication infront of the Service Callout policy.But,still no luck.

<BasicAuthentication async="false" continueOnError="false" enabled="true" name="Basic-Authentication-1">
    <DisplayName>Basic Authentication-1</DisplayName>
    <Operation>Encode</Operation>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <User ref="request.header.user"/>
    <Password ref="request.header.password"/>
    <AssignTo createNew="false">request.header.Authorization</AssignTo>
</BasicAuthentication>

Its working for me now 🙂

I removed HTTP Basic Authentication which was causing issue in sending Authorization header.

And,added Header name in ServiceCallout policy as below

 <Request>
        <Set>
            <Headers>
                <Header name="Authorization">Basic ***************</Header>
            </Headers>
            <Verb>GET</Verb>
        </Set>
    </Request>

Now it is fetching me all the values from a KeyValue Map.

Output :

{ "entry": [{ "name": "400", "value": "Sale4000" }, { "name": "300", "value": "Sale3000" }, { "name": "200", "value": "Sale2000" }, { "name": "100", "value": "Sale1000" }, { "name": "10", "value": "Sale100" }, { "name": "944", "value": "Sale100" } ], "name": "MyCollectionMap" }