I have below DSS
http connection to url:
private static HttpURLConnection connection(String urlSpec) {
HttpURLConnection connection = new URL(urlSpec).openConnection() as HttpURLConnection
connection.setRequestProperty('Prefer', 'respond-async, wait=60')
connection.setRequestProperty('Accept', 'application/json')
connection.setRequestMethod("POST")
connection.setRequestProperty("Content-Type", "application/json; utf-8")
connection.setDoOutput(true)
connection
}
Below is the part of my code where i am checking the http response and if the response is http 200
which is HTTP_OK
then i can fetch the data and insert into database table.
But now the problem is now during processing i am getting now in between Got http error code as 202
which is HTTP_ACCEPTED
and for this reason i am not able to process this data into database table.
I think HTTP 202
is to be expected when requesting async. It means that server has received your query and is working on it. We need to keep checking the status of the request, by retrying the new URL
sent in the 202
response, until you get HTTP 200
. But i dont know how can i do this ?