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
durgam kavyasri
NA
2
560
calling url with its credentials and want to pass the file
Nov 6 2017 5:07 AM
Hi Sir,
I want to call an post method api in the .net service and api has username and password, and also i want to send the file to that api it gives the json data as response.
api is:http://192.168.60.22:8023/mdrf/category/getSheetData
how to pass credentials and file to that api to get the result.
I tried like this but it show an error.
public JsonResult callingurl ()
{
string file = @"E:\maharashtra.xls";
string url = "http://192.168.60.22:8023/mdrf/category/getSheetData";
using (var client = new WebClient { UseDefaultCredentials = true })
{
client.Headers.Add(HttpRequestHeader.ContentType, "application/json; charset=utf-8");
byte[] result = client.UploadFile(url, file);
responseAsString = Encoding.Default.GetString(result);
}
}
error:The remote server returned an error: (401) Unauthorized.
Reply
Answers (
1
)
Program Issues and Help
Cascade ComboBox depends on first one