0

I am trying to create an account on the stellar Test Network. I am using ASP .Net framework. But whenever I make a request and pass in the public key, I always get this error:

Response status code does not indicate success: 400 (Bad Request).

I'll add that I am using the Javascript documentation from here and converting it to C# code because I didn't find any documentation for C#. Is there anything I'm missing out?

this is how the code looks:

try {
  string url = "https://friendbot.stellar.org?addr=" + Uri.EscapeDataString(pair.PublicKey);
  HttpResponseMessage response = await client.GetAsync(url);    
  string responseBody = await client.GetStringAsync(url);
  object responseObject = JsonConvert.DeserializeObject<object>(responseBody);
  return Ok(responseObject);
} catch(Exception ex) {
  return BadRequest("Could not Establish a successful connection with Stellar because " + ex.Message);
}
0

1 Answer 1

0

Finally Got it to work. Switched from using the public key to using the address.

 try
    {
       KeyPair pair = KeyPair.Random();

       string url = "https://friendbot.stellar.org?addr=" + pair.Address;
       string responseBody = await client.GetStringAsync(url);
       object responseObject = JsonConvert.DeserializeObject<object>(responseBody);
       return Ok(responseObject);
    }catch(Exception ex)
        {
          return BadRequest("Could not Establish a connection with Stellar because " + ex.Message);
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.