How to use the Apigee PHP SDK to update an existing developer app

Not applicable

Greetings, all

We're writing code for our portal that uses the Apigee PHP SDK for Edge. I'm writing a php function to update an existing developer app. Specifically, the user should be able to change the name of an existing app. The code works properly when the user changes the API product assigned to the app, but when I try to change the name I get an Apigee exception:

Apigee\Exceptions\ResponseException: Not Found: POST with Content-Length of 265 and Content-Type of in Apigee\Util\APIObject->exec() (line 298 of /var/www/north/profiles/apigee/libraries/mgmt-api-php-sdk/Apigee/Util/APIObject.php).

The approach I'm using is pretty simple. There is no "update()" function for a developer app in the PHP SDK that I can find, so here's what I did:

1) Load the existing developer app by name. This works.

2) Modify the app name by calling DeveloperApp::setName("new app name") on the developer app object instance we just loaded.

3) Save the app and force update by calling DeveloperApp::save(TRUE) to force update on the developer app object instance.

Similar code works well for creating a new developer app. It also works when changing the API product for an existing app -- that updates fine. But it fails when trying to change the name of an existing app.

It seems like the app name may be used as the unique key for the developer app. If that is true and I'm not allowed to change the name because it is the key, then how can I change the name of an existing app?

Solved Solved
1 5 657
1 ACCEPTED SOLUTION

@north.krimsly ,

It's by design. Yes, You guessed it right. APP Name is used as unique key. So, You can't update it & management API call doesn't support it. For more detail refer here.

But, You can use displayName app attribute value to track human Readable name which you can update / edit.

@docs , Can we update Update Developer APP API Documentation with a note saying "App Name" cannot be changed, use display name attribute value to update / track human readable name of App ?

Keep us posted if you have any queries.

View solution in original post

5 REPLIES 5

@north.krimsly ,

It's by design. Yes, You guessed it right. APP Name is used as unique key. So, You can't update it & management API call doesn't support it. For more detail refer here.

But, You can use displayName app attribute value to track human Readable name which you can update / edit.

@docs , Can we update Update Developer APP API Documentation with a note saying "App Name" cannot be changed, use display name attribute value to update / track human readable name of App ?

Keep us posted if you have any queries.

@Anil Sagar Do you mean specify the display name as an attribute of the request body? Do you use an "attribute_name" of "display_name?

{
 "attributes" : [ 
  {
   "name" : "{attribute_name1}",
   "value" : "{value1}"
  }, 
  {
   "name" : "{attribute_name2}",
   "value" : "{value2}"
  } 
 ],
 "name" : "{App_name}",
 "callbackUrl" : "{url}",
 "keyExpiresIn" : "{milliseconds}"
}

Thanks,

Stephen

@sgilson , Request body is fine, We just need to add a note, APP NAME cannot be changed once it's created & if you need a human readable name just use display name attribute.

All set - thanks. Doc updated.

Awesome, Thank you @sgilson for quick action.