Hi all,
I have the following code as example:
I have tried to write this code into VBA, but without success(i cannot login), any idea what im doing wrong:
THe code above is just the example of the vendor...
I have the following code as example:
Code:
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
public class TestLogin1
{
public static void main(String[] args)
{
HttpClient httpClient = new HttpClient();
PostMethod httpPost = null;
try
{
httpPost = new PostMethod("[URL unfurl="true"]https://na.mydomain.com/networking/rest/login");[/URL]
String msg = "<?xml version=\"1.0\"?><mydomain ver=\"2.0\">";
msg += "<login_request><login>youraccount@mydomain</login>";
msg += "<password>your_password</password>";
msg += "</login_request></mydomain>";
httpPost.addParameter("xml_data", msg);
httpClient.executeMethod(httpPost);
String loginResponse = new String(httpPost.getResponseBody());
System.out.println("Login Response \n" + loginResponse);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
httpPost.releaseConnection();
httpClient = null;
}
}
}
I have tried to write this code into VBA, but without success(i cannot login), any idea what im doing wrong:
THe code above is just the example of the vendor...
Code:
Public Sub main()
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Dim myxml As String
myxml = "<?xml version=""1.0""?>" & _
"<mydomain ver=""2.0"">" & _
"<login_request>" & _
"<login>youraccount@mydomain</login>" & _
"<password>your_password</password>" & _
"</login_request>" & _
"</mydomain>"
objHTTP.Open "POST", "[URL unfurl="true"]https://na.mydomain.com/networking/rest/login",[/URL] False, myxml
objHTTP.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
objHTTP.send
result = objHTTP.responseText ' Get the result
MsgBox (result)
End Sub