I am having two worksheets in a spreadsheet. I will copy and change the value from one sheet to other if some conditions are met. It is working for 2 weeks and getting this issu
HTTP error 502 (Bad Gateway) is a server error. There looks to be a problem with one of the Google servers involved in running the spreadsheets API. The problem isn't with your code.
Your computer contacted a Google server, which acted as a proxy for the server that would actually do the work. This second server then encountered a problem of some kind which meant that it could not return a valid response to the proxy server which the proxy could then pass back to you. As a result, the proxy server sent you back an HTTP 502 response.
I would hope that Google's systems would be smart enough to detect these problems and notify Google engineers automatically. Perhaps someone from Google is working on the problem right now. However, I don't work for Google so I can't say that this is true for sure.
If nothing else, you could try posting on the Google Spreadsheets API forum.