Trying to Hit an HTTP request on a specific instance using cloud foundry cli tool

312 Views Asked by At

As part of my POC ,I am trying to hit an http request in pcf using cf cli tool , Sometimes I get proper response as expected sometimes I get below error : **400 Bad Request: Requested instance ('1') with guid ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa') does not exist for route ('example-route.cf.com'). I have 3 routes available for my application deployed in pcf and for one of the route sometimes it generates the above error . I followed the below steps (Cf cli is installed on my machine) :

1.   Run command prompt as administrator

Login to CF CLI using command : “cf login” if you want to select a specific pcf env then use
cf login -a urlOfPCFenv

It will ask for your used id and password ,provide the correct credentials and you will get a message on terminal window : Authenticating... OK

  1.    In a terminal window, retrieve the global unique identifier (GUID) of your app by 
    running:cf app <App-Name> --guid
    

    the output will be like a combo of number and words "12345678-1234-4ab4-1234-
    7a8b9c08d112" and <App-Name> is your application name

  2.    From the terminal output record the guid of your app.
    
  3.    List the app instances and retrieve the index number of the instance you want to hit on 
       by  running the below command :                                                                                                                       
       cf app <App-Name>
    
  4.    From the terminal output, record the index number of your instance (mentioned as # next 
       to state)
    
  5.    Trigger curl request to hit an api to a specific instance :                                                                                        
      curl -H <Authorization: Bearer <jwt>" -H  "X-Cf-App-Instance":"<APP-GUID>:                              
      <INSTANCE-INDEX-NUMBER>" -X  <Request-Mapping> <Api-Uri>
    
    **Eg :**  curl -H "Authorization: Bearer 0003uNnMOXUiYQLRliaxjiX6xbDR"
            -H "X-Cf-App-Instance":"3XXXXX37-48ac-495b-919d-474XXXXXXXX9:0" 
     -X GET https://iXXXXXXXs.api.xxxx.net/app-api-proxy/getDetailsById/XXXXXXX-XXXXX-atr56
    

I followed above steps but sometimes I get below error : 400 Bad Request: Requested instance ('1') with guid ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa') does not exist for route ('example-route.cf.com').

Request you to help with this or if you can suggest any other approach to hit an http request on a specific instance ,It would be great. Thanks

0

There are 0 best solutions below