I'm trying to do the https post to the da api from an asp.net application on a remote server. With every method I try, i'm getting a 401 unauthorized error.
Any suggestions? Thanks!
Public Function CreateUser( _
ByVal UserName As String, _
ByVal Email As String, _
ByVal Password As String, _
ByVal Domain As String, _
ByVal Package As String, _
Optional ByVal IP As String = sIP, _
Optional ByVal Notify As Boolean = True _
) As String
Dim sSubmissionURL As String = sURL & "CMD_ACCOUNT_USER"
Dim sQueryString As String = "action=create&add=Submit"
' Build the query string
sQueryString += "&username=" & UserName
sQueryString += "&email=" & Email
sQueryString += "&passwd=" & Password
sQueryString += "&passwd2=" & Password
sQueryString += "&domain=" & Domain
sQueryString += "&package=" & Package
sQueryString += "&ip=" & IP
If Notify = True Then
sQueryString += "¬ify=yes"
Else
sQueryString += "¬ify=no"
End If
Dim web As New System.Net.WebClient
Web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes(sQueryString)
' In case of problem with certificate
System.Net.ServicePointManager.CertificatePolicy = New MyCertificateValidation
web.Credentials = New NetworkCredential(sAdminUser, sAdminPwd)
Dim res As Byte() = Web.UploadData(sSubmissionURL, sMethod, d)
Any suggestions? Thanks!
Public Function CreateUser( _
ByVal UserName As String, _
ByVal Email As String, _
ByVal Password As String, _
ByVal Domain As String, _
ByVal Package As String, _
Optional ByVal IP As String = sIP, _
Optional ByVal Notify As Boolean = True _
) As String
Dim sSubmissionURL As String = sURL & "CMD_ACCOUNT_USER"
Dim sQueryString As String = "action=create&add=Submit"
' Build the query string
sQueryString += "&username=" & UserName
sQueryString += "&email=" & Email
sQueryString += "&passwd=" & Password
sQueryString += "&passwd2=" & Password
sQueryString += "&domain=" & Domain
sQueryString += "&package=" & Package
sQueryString += "&ip=" & IP
If Notify = True Then
sQueryString += "¬ify=yes"
Else
sQueryString += "¬ify=no"
End If
Dim web As New System.Net.WebClient
Web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes(sQueryString)
' In case of problem with certificate
System.Net.ServicePointManager.CertificatePolicy = New MyCertificateValidation
web.Credentials = New NetworkCredential(sAdminUser, sAdminPwd)
Dim res As Byte() = Web.UploadData(sSubmissionURL, sMethod, d)