TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mayur pandit
1.4k
342
62k
.Net API problem with production credentials
Jan 10 2018 11:42 PM
I have wokring with third party api with post method.
when i use staging credential's of thired party api it's working.
but when i use production credentials it's not woking , it's return
"The remote server returned an error: (400) Bad Request error"
error but production credential's woking in postman application fine.
where is actually gong wrong i don't understand.i have provide here
my code please check and help,
Thank's in advance.
string url = "";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "POST";
string client_id="";
string client_secret = "";
string scope = "";
string grant_type = "";
var postData = "client_id:"+client_id.Trim()+"\r\n";
postData += "client_secret:" + client_secret.Trim() + "\r\n";
postData += "scope:" + scope.Trim() + "\r\n";
postData += "grant_type:"+ grant_type.Trim() +"";
string data = postData; // make sure this is URL encoded
request.ContentType = "application/x-www-form-urlencoded";
using (Stream requestStream = request.GetRequestStream())
using (StreamWriter writer = new StreamWriter(requestStream, Encoding.ASCII))
{
writer.Write(data);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// careful, non-2xx responses will throw an exception
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
string a = reader.ReadToEnd();
}
Reply
Answers (
2
)
Get the value of .Contains in C#
How To get Harddrive Information in Multiple Remote Desktop?