It looks like you're new here. If you want to get involved, click one of these buttons!
func (c *DataController) GetQuote(w http.ResponseWriter, r *http.Request) {
instrumentsQuery := r.URL.Query().Get("instruments")
if instrumentsQuery == "" {
c.logger.Error().Msg("GetQuote request missing 'instruments' query parameter")
http.Error(w, "'instruments' query parameter is required", http.StatusBadRequest)
return
}
instruments := strings.Split(instrumentsQuery, ",")
quoteData, err := c.dataService.GetQuote(r.Context(), instruments)
if err != nil {
c.logger.Error().Err(err).Msg("Failed to fetch quote data")
http.Error(w, "Failed to fetch quote data: "+err.Error(), http.StatusInternalServerError) // Error getting triggered
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(quoteData)
}
dataService is just a gokiteconnect SDK wrapper. This standard is followed on all routes so I dont think its the code having a problem, especially since it works fine on local.
i
. You can know more here.Moreover my backend expects params in the way I send, as seen in the code snippet and it parses and uses the SDK's GetQuote as shared below
https://pkg.go.dev/github.com/zerodhatech/gokiteconnect#:~:text=Client)%20GetQuote%20%C2%B6-,func%20(c%20*Client)%20GetQuote(instruments%20...string)%20(Quote%2C%20error),-GetQuote%20gets%20map
The SDK afaik takes care of parsing the string input and converts it to proper params
You might not be parsing the instruments parameter correctly. It has to be sent as e.g.:
kc.GetQuote("NSE:INFY", "NSE:RELIANCE")
to GetQuote.You can enable HTTP logging by using SetDebug to inspect the issue further and see exactly what's being sent to the API.