Error getting profitability info
donghoonChoe opened this issue · 4 comments
Hello, I am using the python client.
I added this in the public api class, and used the example body in the official document.
def get_profitability(self, speeds):
hashrate_data = {"speeds": {"SCRYPT": 50, "SHA256":20}}
return self.request('POST', '/main/api/v2/public/profcalc/profitability/', '', hashrate_data)
However, every time I run my code, I get this error
Exception: 415: Unsupported Media Type: b'{"error_id":"f4d268dd-91a0-403b-8e7e-3dbd6d8a55fd","errors":[{"code":140,"message":"Unsupported media type"}]}'
Any advices will be helpful!
Thank you
this seems to be generic error ... try adding this two header parameters
Accept: application/json, text/plain, /
Content-Type: application/json;charset=UTF-8
@bl4z tried with your headers added
headers = {
'X-Time': str(xtime),
'X-Nonce': xnonce,
'X-Auth': xauth,
'Accept': 'application/json, text/plain, /',
'Content-Type': 'application/json;charset=UTF-8',
'X-Organization-Id': self.organisation_id,
'X-Request-Id': str(uuid.uuid4())
}
but didn't work 😢
since this is public call just
$url_root = "https://api2.nicehash.com";
$path = "/main/api/v2/public/profcalc/profitability/";
$qs = "";
$postbody = '{"speeds":{"X11":28000,"NIST5":28000,"QUBIT":28000,"QUARK":28000}}';
$postlen = strlen($postbody);
$headers = array(
"Content-Type: application/json",
"Content-Length: {$postlen}"
);
$curl = curl_init();
//curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postbody);
curl_setopt($curl, CURLOPT_URL, $url_root.$path."?".$qs);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
$info = json_decode($result, true);
print_r($info);
@bl4z this works! 😄
I'll try this by python.
thank you for your help 🙏