The PopulateCache policy is not working

Not applicable

Hi All,

I need to populate a cache from the response of a ServiceCallout. but I don't have any particular KeyFragment ref in the response body so I have given response header (content-Type) as populate cache key reference .

<KeyFragment ref="customresponse.header.Content-Type"/> 
<PopulateCache name='xxxx'>
  <DisplayName>Populate Cache 1</DisplayName>
  <Properties/>
  <CacheKey>
    <Prefix/>
    <KeyFragment ref="customresponse.header.Content-Type"/>
  </CacheKey>
  <CacheResource>crtpack</CacheResource>
  <Scope>Application</Scope>
  <ExpirySettings>
    <TimeoutInSec>3600</TimeoutInSec>
  </ExpirySettings>
  <Source>crtId_val</Source>
</PopulateCache>

crtId_val is the variable which value needs to be cached.

crtpack is the cache name .

customresponse is the name of the variable that holds the response from the prior ServiceCallout. and I am getting following error message:

{
  "fault": {
    "faultstring": "java.lang.String cannot be cast to com.apigee.entities.info.EnvironmentInfo",
    "detail": {
      "errorcode": "Internal Server Error"
    }
  }
}

Can anyone suggest some way to resolve this issue?

Thanks

0 3 480
3 REPLIES 3

can you paste your policy xml?

<PopulateCache name='xxxx'>
  <DisplayName>Populate Cache 1</DisplayName>
  <Properties/>
  <CacheKey>
    <Prefix/>
    <KeyFragment ref="customresponse.header.Content-Type"/>
  </CacheKey>
  <CacheResource>crtpack</CacheResource>
  <Scope>Application</Scope>
  <ExpirySettings>
    <TimeoutInSec>3600</TimeoutInSec>
  </ExpirySettings>
  <Source>crtId_val</Source>
</PopulateCache>

crtId_val is the variable which value needs to be cached.

crtpack is the cache name .

adas
New Member

@Ambili Venugopal First of all, I am not too sure why would you want to cache something with a cache key that's coming from the service callout response, especially content-type. Because when you have to lookup the cache you would need that same key, which in this case is the response's content-type. So its sort of defeats the purpose.

You should probably try using something like the request.uri or request.verb or something that uniquely identifies your request or the service callout's request object. If you still see a problem, it would be good to take a look at your api proxy bundle. Please attach the same or email it to me at adas@apigee.com