How to add api proxy to custom roles in apigee using nodejs?

brinda
Participant II

Hi,

I am trying to add an API proxy to some custom roles using Node.js script. I will be getting "API Proxy Name" & "Custom Role Name" as parameters. I am not sure how to start this. Can someone help me out?

0 4 319
4 REPLIES 4

Hi @Chris Hood,

I am trying to use this curl command to add the api proxy to custom role. But it is giving me permission error. Does anyone know what needs to be done to fix permission error?

curl -X POST --header "Content-Type: application/json" -d "{\"resourcePermission\" : [ {\"path\" : \"/applications/{apiproxy}\",\"permissions\" : [ \"get\",\"put\", \"delete\" ]}]}" "https://api.enterprise.apigee.com/v1/organizations/{org}/userroles/{customtestrole}/resourcepermissions" -u email:password

This is the error that I see in runtime logs for nodejs

Nov 1, 2018 9:27:21 AMstderrsvr.0
Nov 1, 2018 9:27:21 AMstderrsvr.0
Nov 1, 2018 9:27:21 AMstderrsvr.0│ npm update check failed │
Nov 1, 2018 9:27:21 AMstderrsvr.0│ Try running with sudo or get access │
Nov 1, 2018 9:27:21 AMstderrsvr.0│ to the local update config store via │
Nov 1, 2018 9:27:21 AMstderrsvr.0│ sudo chown -R $USER:$(id -gn $USER) /root/.config
Nov 1, 2018 9:27:21 AMstderrsvr.0

HI @Brinda Marfatia

Check this repo I built sometime back. You need Maven to deploy the proxy. This proxy will be able to create the API Proxy and assign the specific custom role.

brinda
Participant II

I am trying to use this curl command to add the api proxy to custom role. But it is giving me permission error. Does anyone know what needs to be done to fix permission error?

curl -X POST --header "Content-Type: application/json" -d "{\"resourcePermission\" : [ {\"path\" : \"/applications/{apiproxy}\",\"permissions\" : [ \"get\",\"put\", \"delete\" ]}]}" "https://api.enterprise.apigee.com/v1/organizations/{org}/userroles/{customtestrole}/resourcepermissions" -u email:password

This is the error that I see in runtime logs for nodejs

Nov 1, 2018 9:27:21 AMstderrsvr.0
Nov 1, 2018 9:27:21 AMstderrsvr.0
Nov 1, 2018 9:27:21 AMstderrsvr.0│ npm update check failed │
Nov 1, 2018 9:27:21 AMstderrsvr.0│ Try running with sudo or get access │
Nov 1, 2018 9:27:21 AMstderrsvr.0│ to the local update config store via │
Nov 1, 2018 9:27:21 AMstderrsvr.0│ sudo chown -R $USER:$(id -gn $USER) /root/.config
Nov 1, 2018 9:27:21 AMstderrsvr.0