# Not getting response when i am calling api call first time

**URL:** <https://forum.rasa.com/t/not-getting-response-when-i-am-calling-api-call-first-time/15585>\
**Category:** Rasa Open Source\
**Created:** [September 12, 2019, 11:30am UTC](https://forum.rasa.com/t/not-getting-response-when-i-am-calling-api-call-first-time/15585 "2019-09-12T11:30:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![surya1994](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@surya1994](https://forum.rasa.com/u/surya1994)\
**Post date:** [September 12, 2019, 11:30am UTC](https://forum.rasa.com/t/not-getting-response-when-i-am-calling-api-call-first-time/15585/1 "2019-09-12T11:30:25Z")

</div>

HI

I am not getting response when i call the API call for the first time in day (it calls action class and wait for it to response and finally gives response as down even though the api works fine in postmen) i tried lot of methods but still i did not find what is the reason for this issue.Can you please help me with this.

below is error i am getting at which api calls get fail:

```auto
common_url https://xxxxxx/xxx-xxx/api/secure/v1/user/landing
***********paramsLanding************* {'userId': 'myusername', 'requestHeader': {'securityCredential': {'userName': 'myusername', 'securityToken': 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzdXJ5YTE5OTMiLCJqdGkiOiJzdXJ5YTE5OTMiLCJ1c2VyTmFtZSI6InN1cnlhMTk5MyIsImlhdCI6MTU2ODI4NTMzNywiZXhwIjoxNTY4MjkyNTM3fQ.0vRG_JP3IXoE6X2acgOx3_96o5xYMYyfXVN5IBNXIUI'}}}
***********inputDataLanding************* {"userId": "myusername", "requestHeader": {"securityCredential": {"userName": "myusername", "securityToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzdXJ5YTE5OTMiLCJqdGkiOiJzdXJ5YTE5OTMiLCJ1c2VyTmFtZSI6InN1cnlhMTk5MyIsImlhdCI6MTU2ODI4NTMzNywiZXhwIjoxNTY4MjkyNTM3fQ.0vRG_JP3IXoE6X2acgOx3_96o5xYMYyfXVN5IBNXIUI"}}}
2019-09-12 06:48:57 DEBUG urllib3.connectionpool - Starting new HTTPS connection (1): myappapi.dev5.awse1.mycompany.com:443
/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)

```

actions.py:

```auto
class ActionOutAmontpreProcess(Action):
   def name(self):
        # define the name of the action which can then be included in training stories
       return "action_outstanding_amount_preprocess"
   def run(self, dispatcher, tracker, domain):
       print(" ****User login validation started***")
       user_id= tracker.get_slot('user_id')
       password= tracker.get_slot('password')
       common_url=tracker.get_slot('common_url')
       print("The user_id is",user_id)
       print("The password is",password)
       print("The common Url is",common_url)
       API_ENDPOINT= common_url+"/xxx-xxx/api/public/v1/user/myappLogin"
       print("common_url for preprocess",API_ENDPOINT)
       params={"userName":user_id,"password":password}
       inputData=json.dumps(params)
       try:
        response = json.loads(requests.post(url=API_ENDPOINT,data=inputData,verify=False).text)
        statusCheck=response["loginStatus"]
        print(statusCheck)
        API_ENDPOINT_JWT= common_url+"/xxx-xxx/api/secure/v1/user/generateJWTToken"
        print("API_ENDPOINT_JWT",API_ENDPOINT_JWT)
        paramsjwt={"userId":user_id,"requestHeader":{"appId":"EEA","securityCredential":{"userName":user_id,"securityToken":""}}}
        print("paramsjwt",paramsjwt)
        inputjwt=json.dumps(paramsjwt)
        responsejwt = json.loads(requests.post(url=API_ENDPOINT_JWT,data=inputjwt,verify=False).text)
        jwt_token=responsejwt["jwtToken"]
        print("jwt_token",jwt_token)
        if(statusCheck=="SUCCESS"):
          print(" *******Login Success************")
          API_ENDPOINT_Landing_Response= common_url+"/xxx-xxx/api/secure/v1/user/landing"
          print("user_id",user_id)
          print("common_url",API_ENDPOINT_Landing_Response)
          paramsLanding={"userId":user_id,"requestHeader":{"securityCredential":{"userName":user_id,"securityToken":jwt_token}}}
          print(" ***********paramsLanding*************",paramsLanding)
          inputDataLanding=json.dumps(paramsLanding)
          print(" ***********inputDataLanding*************",inputDataLanding)
          api=requests.post(url=API_ENDPOINT_Landing_Response,data=inputDataLanding,verify=False)
          print("success",api)
          responseLanding = json.loads(api.text)
          print("success",responseLanding)
          group_number=responseLanding["myappUserAccessDetails"][0]["groupNumber"]
          firstName=responseLanding["firstName"]
          lastName=responseLanding["lastName"]
          user_name=firstName+lastName
          Email=responseLanding["emailAddress"]
          groupname=responseLanding["myappUserAccessDetails"][0]["groupName"]               
          print("group Number is",group_number)
          print("User Name is",user_name)
          print("Email",Email)
          print("groupname",groupname)
          return [SlotSet("group_num",group_number),SlotSet("user_name",user_name),SlotSet("Email_address",Email),SlotSet("group_name",groupname),SlotSet("err_reason","noerror")]
        else:
         #dispatcher.utter_message("The User ID or Password entered is Incorrect.")
          print("Loginfailed")
          return[SlotSet("err_reason","loginfail")]
       except:
         print("Error",sys.exc_info()[0])
         print(" *******System is down at this point of time******")
         checkValue="bill empty"
         return [SlotSet("err_reason",checkValue)]

```

---

<div class="post-metadata">

**Author:** ![erohmensing](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/erohmensing/32/1789_2.png) [@erohmensing](https://forum.rasa.com/u/erohmensing)\
**Post date:** [September 12, 2019, 12:13pm UTC](https://forum.rasa.com/t/not-getting-response-when-i-am-calling-api-call-first-time/15585/2 "2019-09-12T12:13:04Z")

</div>

Can you post what happens in the rasa console when it fails? Ideally on `--debug` mode

---

<div class="post-metadata">

**Author:** ![surya1994](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@surya1994](https://forum.rasa.com/u/surya1994)\
**Post date:** [September 12, 2019, 1:02pm UTC](https://forum.rasa.com/t/not-getting-response-when-i-am-calling-api-call-first-time/15585/3 "2019-09-12T13:02:37Z")

</div>

The action get called for lot of time and finally i am getting system down message.but API call works fine when i check in postman.

error:

```auto
common_url https://xxxxxx/xxx-xxx/api/secure/v1/user/landing
***********paramsLanding************* {'userId': 'myusername', 'requestHeader': {'securityCredential': {'userName': 'myusername', 'securityToken': 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzdXJ5YTE5OTMiLCJqdGkiOiJzdXJ5YTE5OTMiLCJ1c2VyTmFtZSI6InN1cnlhMTk5MyIsImlhdCI6MTU2ODI4NTMzNywiZXhwIjoxNTY4MjkyNTM3fQ.0vRG_JP3IXoE6X2acgOx3_96o5xYMYyfXVN5IBNXIUI'}}}
***********inputDataLanding************* {"userId": "myusername", "requestHeader": {"securityCredential": {"userName": "myusername", "securityToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzdXJ5YTE5OTMiLCJqdGkiOiJzdXJ5YTE5OTMiLCJ1c2VyTmFtZSI6InN1cnlhMTk5MyIsImlhdCI6MTU2ODI4NTMzNywiZXhwIjoxNTY4MjkyNTM3fQ.0vRG_JP3IXoE6X2acgOx3_96o5xYMYyfXVN5IBNXIUI"}}}
2019-09-12 06:48:57 DEBUG urllib3.connectionpool - Starting new HTTPS connection (1): myappapi.dev5.awse1.mycompany.com:443
/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
calling 'action_outstanding_amount_preprocess'

```

---

<div class="post-metadata">

**Author:** ![erohmensing](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/erohmensing/32/1789_2.png) [@erohmensing](https://forum.rasa.com/u/erohmensing)\
**Post date:** [September 12, 2019, 1:21pm UTC](https://forum.rasa.com/t/not-getting-response-when-i-am-calling-api-call-first-time/15585/4 "2019-09-12T13:21:23Z")

</div>

None of those look like errors, just a debug message

---

<div class="post-metadata">

**Author:** ![surya1994](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@surya1994](https://forum.rasa.com/u/surya1994)\
**Post date:** [September 13, 2019, 2:57pm UTC](https://forum.rasa.com/t/not-getting-response-when-i-am-calling-api-call-first-time/15585/5 "2019-09-13T14:57:09Z")

</div>

Below is the error i am getting

common\_url [https://companylink/api/secure/v1/user/landing](https://companylink/api/secure/v1/user/landing)_ **paramsLanding** _\*\* {‘userId’: ‘username’, ‘requestHeader’: {‘securityCredential’: {‘userName’: ‘username’, ‘securityToken’: ‘eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzdXJ5YTE5OTMiLCJqdGkiOiJzdXJ5YTE5OTMiLCJ1c2VyTmFtZSI6InN1cnlhMTk5MyIsImlhdCI6MTU2ODM4NTcxOSwiZXhwIjoxNTY4MzkyOTE5fQ.8VmwYLdteFcToYC-Pu32knGKsiAPnjyWte2WpLsSDpw’}}} _ **inputDataLanding** _\*\* {“userId”: “username”, “requestHeader”: {“securityCredential”: {“userName”: “username”, “securityToken”: “eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzdXJ5YTE5OTMiLCJqdGkiOiJzdXJ5YTE5OTMiLCJ1c2VyTmFtZSI6InN1cnlhMTk5MyIsImlhdCI6MTU2ODM4NTcxOSwiZXhwIjoxNTY4MzkyOTE5fQ.8VmwYLdteFcToYC-Pu32knGKsiAPnjyWte2WpLsSDpw”}}} 2019-09-13 10:41:59 DEBUG urllib3.connectionpool - Starting new HTTPS connection (1): companylink:443 /u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: [Advanced Usage — urllib3 1.25.3 documentation](https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings) InsecureRequestWarning) 2019-09-13 10:46:59 DEBUG urllib3.connectionpool - [https://projectapi.dev5.awse1.mycompany](https://projectapi.dev5.awse1.mycompany) .com:443 “POST /eea-user/api/secure/v1/user/landing HTTP/1.1” 504 148 success \<Response [504]\> Error \<class ‘json.decoder.JSONDecodeError’\> \*\*\*\*\*\*\* System is down at this point of time \*\*\*\*\*\* 2019-09-13 10:46:59 DEBUG rasa\_sdk.executor - Finished running ‘action\_outstanding\_amount’

when i am calling api

---

<div class="post-metadata">

**Author:** ![erohmensing](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/erohmensing/32/1789_2.png) [@erohmensing](https://forum.rasa.com/u/erohmensing)\
**Post date:** [September 13, 2019, 2:59pm UTC](https://forum.rasa.com/t/not-getting-response-when-i-am-calling-api-call-first-time/15585/6 "2019-09-13T14:59:25Z")

</div>

Then there must be something wrong with your code where you call the API, it’s not a rasa issue. You have it in one huge try/except block (and aren’t excepting any specific errors) which isn’t very good for degbugging – i’d recommend taking the try/except away for now and debugging it.
