Logout error

amitabhchoudhury
@sujith and @rakeshr

Was trying with first program and got following Exception message in when trying to print JSONObject returned by logout. What could be the reason?

~~~
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "java.util.Map$Entry.getValue()" is null
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.createDeleteRequest(KiteRequestHandler.java:281)
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.deleteRequest(KiteRequestHandler.java:131)
at com.zerodhatech.kiteconnect.KiteConnect.invalidateAccessToken(KiteConnect.java:996)
at com.zerodhatech.kiteconnect.KiteConnect.logout(KiteConnect.java:982)
at tests.KiteLogin.main(KiteLogin.java:25)
C:\(folder info removed)\AppData\NetBeans\Cache\14\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\(folder info removed)\AppData\Local\NetBeans\Cache\14\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 8 seconds)
~~~

Code:
String url = kiteConnect.getLoginURL();
System.out.println(url);
JSONObject jsonObject10 = kiteConnect.logout();
System.out.println(jsonObject10);


Please inform.

Warm wishes
  • amitabhchoudhury
    Maybe because I didnt include following before connection
    ~~~
    User user = kiteConnect.generateSession("xxxxxtttyyy", "xxxxxxxyyyyy");
    kiteConnect.setAccessToken(user.accessToken);
    kiteConnect.setPublicToken(user.publicToken);
    ~~~
  • amitabhchoudhury
    In Test class following code was shown to obtain
    User user = kiteConnect.generateSession("xxxxxtttyyy", "xxxxxxxyyyyy");
    How to get request token from Java code? Any method available?

  • amitabhchoudhury
    @sujith and @rakeshr

    Was check the access token flow in one of the videos using ipython.
    Is there any video on Java apis?

    Unable to understand the flow.
  • sujith
    You can refer to the login flow here.
    Once you obtain an access token, you can use it for the whole day. Don't call generate session every time you run the app.
    You may also refer to the FAQs here.
  • amitabhchoudhury
    Thanks @sujith for the patient reply. I am framing my query in another post. Please guide me with setting up my system.

    You may close this thread and the previous thread.
  • sujith
    Kite Connect is purely an execution platform. We don't provide support for writing strategies. You can check out our documentation, FAQs and examples of javakiteconnect.
  • amitabhchoudhury
    amitabhchoudhury edited February 2023
    @sujith I am not asking for strategies. I mentioned "setting up" doesn't mean strategies. It means the regular workflow. It meant connecting with your execution platform.

    Another point I would like to place here. I am paying for the the api access. This is not a free access. If Apache says " You can check out our documentation, FAQs and examples " thats fine.

    The documentation isn't exhaustive as the Apache Foundation. Examples aren't exhaustive as Apache Foundation or Google API.

    The support I expect is for setting up the system, which doesn't mean strategies ofcourse.
    The support I expect is for examples that cover all aspect of the execution platform installation.

    The Java API documentation and support is sparse. Focus is on Python.

    With due respect that you all have placed in making this execution platform accessible, I would say, that this support I am asking is not for free.

    Zerodha support informed to come to this forum for all technical problems. So I am here and paying for the support you all are providing. Please don't use the language of a freebee giver. Atleast from my perspective I am paying for the support I am asking for.

    Warm wishes


  • stevejonn
    The "Exception in thread 'main' java.lang.NullPointerException" error in Java occurs when your code attempts to use a null object reference, i.e., an object that has not been initialized or has been set to null.

    To fix this error, you need to identify the null reference and either initialize the object or assign a value to it before using it. Here are some common causes of this error:

    Attempting to call a method on a null object reference
    Trying to access or modify a variable that has not been initialized
    Passing a null value as an argument to a method that does not allow null values

    To avoid this error, always ensure that objects are properly initialized before they are used, and check for null values before attempting to use them. You can also use tools like debugging and logging to help identify the cause of the null reference.


Sign In or Register to comment.