こんにちは、ユーザー名とパスワードとして認証を行う外部 REST API を呼び出そうとしています。 認証なしのAPIを呼び出す方法までコードを書くことができましたが、今ではユーザー名とパスワードを渡したいときに打たれます。
これは私のコードです
私が試したこと:
C#
public static string username = "xxx"; public static string password = "xxx"; public static string uri = "https://1.1.1.1/x/x";< webrequest req = webrequest.create(uri); req.method = "GET"; httpwebresponse res = null; res = (httpwebresponse)req.getresponse(); string resu = null; using (stream stm = res.getresponsestream()) { streamreader sr = new streamreader(stm); resu = sr.readtoend(); sr.close(); } }
コメント