Need help debugging KVM proxy

Hello Friends,

I am close on having a simple kvm proxy to write my google service account api key, but it wont take. I can confirm my gcp-kvm map exists through the Apigee Management API with:

GET https://apigee.googleapis.com/v1/organizations/myproject/environments/eval/keyvaluemaps/

However, my KVM PUT operation doesn't set the value like it should. I have tinkered around with it, and I just need another set of eyes to help me finish the last pixel that is off.

My curl command is

curl -X POST -k -H "Authorization: Bearer xyxyxyxyxyxyxyxyxyxyxyxyxyx" https://myproject-eval.apigee.net/gcp-kvm-admin -d "private_key=yxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy"

it returns 200 with a payload:

{"requested" : yxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy,           
 "message" : "success",           
 "private_key":           
}

so I know request.fromparam.private_key is being read, and I have traced it and the value seems to be there.

my proxies are attached. I am used a sharedflow for the GET operation so I can use it from other proxies that need access to this value.

Thanks so much for your support . It truly is invaluable.

Solved Solved
1 2 191
1 ACCEPTED SOLUTION

ok I see a couple problems.

  1. In line 11 of your apiproxy/proxies/default.xml, you have an empty <Flows/> element. Then later in the same file you have a <Flows> element that has children. Not sure what happens when you duplicate the Flows element. Better to remove the empty one.
  2. In your sharedflowbundle/sharedflows/default.xml , there is no step. It looks like this:

    <SharedFlow name="default"></SharedFlow>
    	

    I think you need to add a step, like this:

    <SharedFlow name="default">
        <Step>
            <Name>KVM-GET-GCP-KEY</Name>
        </Step>
    </SharedFlow>
    	
  3. Maybe most importantly, in apiproxy/policies/PUT-GCP-API-KEY.xml, on line 11, the ref= attribute uses curly braces. It shouldn't. You have:

            <Value ref="{request.formparam.private_key}"/>
    	

    You should have:

            <Value ref="request.formparam.private_key"/>
    	
  4. You didn't ask, but... it might be nice to conform to the Apigee naming recommendations for your policies. For example, use a prefix of AM- for AssignMessage. and so on.

Please find attached a working version of your proxy and sharedflow.

get-g-apikey-rev3-2021-03-31.zip

kvm-admin-rev5-2021-03-31.zip

View solution in original post

2 REPLIES 2

ok I see a couple problems.

  1. In line 11 of your apiproxy/proxies/default.xml, you have an empty <Flows/> element. Then later in the same file you have a <Flows> element that has children. Not sure what happens when you duplicate the Flows element. Better to remove the empty one.
  2. In your sharedflowbundle/sharedflows/default.xml , there is no step. It looks like this:

    <SharedFlow name="default"></SharedFlow>
    	

    I think you need to add a step, like this:

    <SharedFlow name="default">
        <Step>
            <Name>KVM-GET-GCP-KEY</Name>
        </Step>
    </SharedFlow>
    	
  3. Maybe most importantly, in apiproxy/policies/PUT-GCP-API-KEY.xml, on line 11, the ref= attribute uses curly braces. It shouldn't. You have:

            <Value ref="{request.formparam.private_key}"/>
    	

    You should have:

            <Value ref="request.formparam.private_key"/>
    	
  4. You didn't ask, but... it might be nice to conform to the Apigee naming recommendations for your policies. For example, use a prefix of AM- for AssignMessage. and so on.

Please find attached a working version of your proxy and sharedflow.

get-g-apikey-rev3-2021-03-31.zip

kvm-admin-rev5-2021-03-31.zip

Thanks so much Dino for the help. Also thanks for the advise on Apigee naming conventions and for taking the liberty of renaming the policies. I will edit my other proxies the best I can to keep the code more readable by other (Apigeesters?) who may need to work on them down the road.