I am trying to call an API using this code:
let client = reqwest::Client::new();
let request_url = "https://mainnet-algorand.api.purestake.io/idx2/v2/assets/2751733/balances?currency-greater-than=0";
let response = client
.get(request_url)
.header("x-api-key", "some_token")
.header(CONTENT_TYPE, "application/json")
.header(ACCEPT, "application/json")
.header("pragma", "public")
.send()
.await?;
println!("{:?}", response);
However , I get this response:
Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("mainnet-algorand.api.purestake.io")), port: None, path: "/idx2/v2/assets/2751733/balances", query: Some("currency-greater-than=0"), fragment: None }, status: 200, headers: {"content-type": "application/json", "content-length": "153844", "connection": "keep-alive", "date": "Fri, 20 May 2022 18:25:38 GMT", "x-amzn-requestid": "097f7ef4-c2eb-4f14-bdbb-2dea89b64cb4", "access-control-allow-origin": "*", "x-amz-apigw-id": "Sb99aGZAYosFYLw=", "x-amzn-trace-id": "Root=1-6287dd22-4f2782c668a46b573d923f7b", "x-cache": "Miss from cloudfront", "via": "1.1 649f2d5b78b576a4e054c850d1f18e2e.cloudfront.net (CloudFront)", "x-amz-cf-pop": "DXB50-C1", "x-amz-cf-id": "_jQfa-0GCf1nsAQHJ3EjHsDNfaU5lOeUWydITLCKTCVScNVO1cZsTA=="} }
This is my expected response.
{"balances":[{"address":"AACCDJTFPQR5UQJZ337NFR56CC44T776EWBGVJG5NY2QFTQWBWTALTEN4A","amount":0,"deleted":false,"is-frozen":false,"opted-in-at-round":19008955},{"address":"AACVS4SV4HQMODFOQQWTYMDWVK4HXRCZJY3YBOTOKGLKPS3KL25ZYWPEVE","amount":0,"deleted":false,"is-frozen":false,"opted-in-at-round":11648878},{"address":"AAD5NOIWG5PAVGXNGUHB2QOBEP25TECM6HEH2M77JH6SVRZATT4GTDNE54","amount":0,"deleted":false,"is-frozen":false,"opted-in-at-round":11671802},{"address":"AAE6PW7E2JB7ILDCY5E4EYNGF3EPY7IA2AHS6IXV4K6AHNJDXA4AMRMRQQ","amount":9,"deleted":false,"is-frozen":false,"opted-in-at-round":16772798},{"address":"AAG5TXAOZM5BFTUY7QTSDBGD624WZ7XRLRIOBHQGIWOVILTAAGAS72JKT4","amount":0,"deleted":false,"is-frozen":false,"opted-in-at-round":17115104},{"address":"AASPDWFB2A6VMK6Q4MDWN3CHV2CPGFVAZWTCTXA76XG6A2O6DD3CQTOEZY","amount":0,"deleted":false,"is-frozen":false,"opted-in-at-round":11672815},{"address":"AAS4IWZK4TCQ6XNWPVE42WVSSPWPE3CHSQSFMOODFN3T4BQCVUCWYQFXCM","amount":61364525,"deleted":false,"is-frozen":false,"opted-in-at-round":16965159},{"address":"AAT6HFLOWBPXL4WW6BS7SSL2QXGBXBRXXE3WKMDQGJLOF6SJL3C2BKLPB4","amount":0,"deleted":false,"is-frozen":false,"opted-in-at-round":11674203},{"address":"AAWXFICZXSESKJRINCZCABPJBEG635D4JQMEOHWDHMICIPTL3IZUDAV2FI","amount":3,"deleted":false,"is-frozen":false,"opted-in-at-round":16996159},{"address":"AAYE4NCMW7OXCDZYVYW7J4W3ZLC45FAX5QMT4Q3AWPJ24MEOKJNWHEM2SY","amount":2,"deleted":false,"is-frozen":false,"opted-in-at-round":16965295},{"address":"ABAVFHUM7FMOGH4PL2XBUXJM3NNRSVNVEDK5FB74NOPSKKGOD5KJWZPSHI","amount":0,"deleted":false,"is-frozen":false,"opted-in-at-round":17141006}
I would appreciate pointers on what i am doing wrong
According to the reqwest docs, you need to use the text()
method on the Response
struct to get the raw text. The code you have current prints out the Response
struct, not its content.