I have this code here in python
response = requests.post(
"https://gateway.watsonplatform.net/personality-insights/api/v2/profile",
auth = ("username", "password"),
headers = {"content-type": "text/plain"},
data = "your text goes here"
)
jsonProfile = json.loads(response.text)
I am trying to convert it to C#, below is my code:
public void getRequest() {
string url = "https://gateway.watsonplatform.net/personality-insights/api/v2/profile";
using (var client = new WebClient())
{
var values = new NameValueCollection();
values["username"] = username;
values["password"] = password;
values["content-type"] = "text/plain";
values["data"] = getTestWords(@"D:\Userfiles\tchaiyaphan\Documents\API and Intelligence\storyTestWord.txt");
var response = client.UploadValues(url, values);
var responseString = Encoding.Default.GetString(response);
}
}
I don't know what to do with header section so i left that out. And when i ran the code it gave me an 401 error. I dont know what to do!
usernameandpasswordWebClient.Headers!