Reputation: 590
I want to post json to the server, I created json and passing it. But getting The remote server returned an error: (401) Unauthorized error. Can some one help me with that.
I have posted my code:----------------------------------------------------------
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://synapsepay.com/api/v2/user/create");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"email\":\"[email protected]\"," +
"\"fullname\":\"nik\"," +
"\"phonenumber\":\"111\"," +
"\"ip_address\":\"1.1.1.1.1\"," +
"\"password\":\"123123123\"," +
"\"client_id\":\"116db45feb835d2cd5d2\"," +
"\"client_secret\":\"ba1c5db06d50d047ac294f4acb31cf0958bcfdf6\"}";
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
}
I have posted required fields below:--------------------------------------------
Request Headers requires:-
Accept: */*
Content-Type: application/json
accept-encoding: gzip
content-length: 280
Request Data:- only email, full name, phonenumber and ip_address, client id and client secrate is mandatory This is accepted input, from their website.
{
"email": "[email protected]",
"fullname": "nikunj mange",
"phonenumber": "4089170880",
"ip_address": "1.1.1.1.1",
"dp": "a",
"password": "123123",
"client_id": "@@@@@@@@@@@@@@@@@",
"client_secret": "#######################################"
}
I dont know what i am doning wrong..
and this is the API I am using.
http://api.synapsepay.com/v2.0/docs/create-a-usercustomer
Upvotes: 0
Views: 4872
Reputation: 58522
You are getting an email already exists error.
You need to check the response and look at the "success flag & reason.
Upvotes: 1