Open anandvijay094 opened 3 years ago
For which platform are you building your software? @anandvijay094
How to make a call at Certificate api using bearer token and benifiary Id ? is this the correct way in Flutter.
http.get("/url/beneficary_reference_id?=ID",headers:{ 'Authorization':'Bearer $token' });
How to make a call at Certificate api using bearer token and benifiary Id ? is this the correct way in Flutter.
http.get("/url/beneficary_reference_id?=ID",headers:{ 'Authorization':'Bearer $token' });
Why are you passing
For which platform are you building your software? @anandvijay094
React
Why are you passing bearer, it can be like 'Authorization': '$token'
The CoWin website sends it as Authorisation: "bearer \<token\>
. Since no documentation is provided in API Setu, it is taken as the "standard" way.
@kichappa It does not seem to help anyway. I am getting Unauthenticated access in calling certificate API. I tried calling API this way in Flutter
final response = await http.get( Uri.parse('https://cdn-api.co-vin.in/api/v2/registration/certificate/download?beneficiary_reference_id?=$referenceId'), headers: { 'content-type': 'application/pdf', 'responseType': 'blob', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36', 'authorization': 'Bearer $token', }, );
For which platform are you building your software? @anandvijay094
React
If you just create a .txt file and put all the binary contents in that file and then change extension to .pdf it will be opened
If you just create a .txt file and put all the binary contents in that file and then change extension to .pdf it will be opened
I already tried this but it's not working .
@kichappa It does not seem to help anyway. I am getting Unauthenticated access in calling certificate API.
@parjanyaacoder, your URL seems to be wrong.
Uri.parse('https://cdn-api.co-vin.in/api/v2/registration/certificate/download?beneficiary_reference_id?=$referenceId')
It should be
Uri.parse('https://cdn-api.co-vin.in/api/v2/registration/certificate/download?beneficiary_reference_id=$referenceId'),
I used the following code on python,
import requests. pathlib
bearer_token = "your bearer token"
URL = "https://cdn-api.co-vin.in/api/v2/registration/certificate/download?beneficiary_reference_id={}".format(beneficiary_reference_id)
response = requests.get(URL, headers={
"accept": "application/json",
"Accept-Language": "en_US",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
"authorization": "Bearer {}".format(bearer_token)
})
with pathlib.Path("certificate.pdf") as f:
f.write_bytes(response.content)
This works fine for me, giving me the certificate as a pdf
.
@kichappa I have solved this issue. Please check issue #61 and give your inputs. I am stuck on that.
@kichappa I have solved this issue. Please check issue #61 and give your inputs. I am stuck on that.
@parjanyaacoder, what is the exact problem you are facing. That issue thread is very vague, and I am not sure where you are stuck.
Getting this as a pdf. This is what I am getting as response from cowin certificate api. Used file.writeAsBytes to store in a pdf file but getting this as output.
@parjanyaacoder did you try using the write_bytes()
method?
Edit: Also, rename the file to have pdf
as its extension. The image shows a filename certificate
, without any extensions.
Hi I am trying to decode the downloaded file in android can someone help me in this, already tried assuming it is of type Base64. If someone know the downloaded file format please let me know.
@kichappa I have tried your code snippet for generating the certificate. Its shows 401 error continuously. Everything else is correct idk whats happening. Any possibility that the code you pasted has a bug?
For which platform are you building your software? @idevesh
hey can you provide me your kotlin code of downloading certificate from api
For which platform are you building your software? @idevesh
hey can you provide me your kotlin code of downloading certificate from api @shivamPatwal
val certFile = File( PATH, "certificate" + "_covid19" + ".pdf" ) try { val certFOS = FileOutputStream(certFile) certFOS.write(t.bytes()) // t is the binary response from Cowin API certFOS.close() } catch (e: Exception) { showToast(getString(R.string.some_error_occurred)) }
Use Retrofit to call the API.
For which platform are you building your software? @idevesh
hey can you provide me your kotlin code of downloading certificate from api @shivamPatwal
val certFile = File( PATH, "certificate" + "_covid19" + ".pdf" ) try { val certFOS = FileOutputStream(certFile) certFOS.write(t.bytes()) // t is the binary response from Cowin API certFOS.close() } catch (e: Exception) { showToast(getString(R.string.some_error_occurred)) }
Use Retrofit to call the API.
t.bytes() method is not present in kotlin i have use toByteArray method but pdf file is blank size is correct but there is no any content written on the pdf file. Please help me
@shekharkumar86 I am also stucked on the same point. If anyone have solved it please help
after using bearer token & benificiary id i m getting binary data of Vaciination Certificate . how to convert it into pdf ??