Null Pointer exception in calling get request

Cannot get the response of api that i am running. debugger stops at the line when it is called and gives null pointer exception . Tried all the faqs and Tried getForEntity,exchange,getForObject

In this case the start date is after the end date. @Samyak_Jain

but in documentation and todo start date comes first

NO bro @Samyak_Jain I meant start date is 2nd Jan 2019 and end date is 1st Jan 2019.

Your endDate is less then startDate.

@Samyak_Jain, another thing I want to tell you is that, don’t share your API key publicly. Others can pretend to be you and use up your limited API calls. It should always be kept private.

see these were the todos
// 2. startDate = purchaseDate in portfolio_trade.
// 3. endDate = args[1]
u need to extract purachsedate from the object u were mapping and endate will be ur agrs through terminal…and in no case enddate will be less than start date.

@ankushshetkar16 Thanks for the advice and explanation. Late night mistakes :stuck_out_tongue: Clearly visible but i was unable to see

1 Like

I have put the check on date but same error is coming
Even if am using documentaion example then also this error is coming

What happens when you click on the url, what does the browser say?
Do you see “Please supply a token” in vscode or browser?

in browser output is coming perfect. when i check using curl and also in program it is giving this error

When you use curl remember to put the url in double quotes “url”

Thanks work for curl too but url should be in String format right? how to debug that why that it is not accepting?

Try setting breakpoints and debug, try to check the http response status.

Can’t get the request running and while setting breakpoint it throws null pointer exception and do not give status code.

Checkout where you’re getting null pointer exception and see why are you getting it. Try setting breakpoint before the statement which gives you null pointer exception.

The line where i am calling exchange method is giving error i have tried all the combinations and also getForEntity but same exception

Check RestTemplate documentation for getForObject();

I checked and implemented the same but can’t get out of that. What can i do next?

Hey have you thought for the case when endDate is not given and then you have to use current_date as your end date.