3

I Need API to stop the running application, after some search I've found this API

http://apidocs.cloudfoundry.org/263/apps/updating_an_app.html

if I want to test it with postman how can I obtain token and where should I put it inside postman ?

Edit

i've tried like following with postman

Put https://[api]/v2/apps/211c82e2-7316-45b6-9ae6-1df4dzz74772/stop

Header

Authorization : bearer <token>
"Content-Type":"application/x-www-form-urlencoded"

I got error:

{
    "description": "Unknown request",
    "error_code": "CF-NotFound",
    "code": 10000
}

Any idea?

1 Answers1

1

To get the token you can run cf oauth-token from the CLI.

You can use that token in Postman by adding an 'Authorization' HTTP header.

E.g.

Authorization: bearer token_you_got_by_running_cf_oauth-token
nimeshjm
  • 1,665
  • 10
  • 13
  • 1
    Another option is to just use `cf curl`. It doesn't have a pretty gui, but it will take care of sending the token and also refreshing it as needed since the token you get from `cf oauth-token` will expire. – Daniel Mikusa Jul 22 '17 at 21:11
  • @DanielMikusa - Please see my edit if you can help. Thanks! –  Jul 23 '17 at 08:05
  • btw, when I run the app summery api (with token etc) everything is working fine... just the update API give error, any idea what could be missing in the request ? –  Jul 23 '17 at 10:35
  • 1
    When in doubt, run `CF_TRACE=true cf ` to see what API end points need to be called. In this case, there is no `/v2/apps/211c82e2-7316-45b6-9ae6-1df4dzz74772/stop` end point. It should be a PUT to `/v2/apps/211c82e2-7316-45b6-9ae6-1df4dzz74772` with a body of `{"state":"STOPPED"}`. – Daniel Mikusa Jul 23 '17 at 14:14