Showing results for 
Search instead for 
Did you mean: 

403 Forbidden

Occasional Participant

403 Forbidden

I read through most of the forums and tried all the fixes and I'm still getting an error. Our registration process is classic asp/vbscript and I've used the following code:


UN = "myheroproject" 
PW = "[pw]"
API_Key = "f504fafc-[...]6050" 

response.write(PostDataToURL(List_ID,FirstName,LastName,EmailAddress,PostalCode, "POST", UN,PW,API_Key)) 

Function PostDataToURL(List_ID,FirstName,LastName,EmailAddress,PostalCode, strMethod, UN,PW,API_Key)
Dim lngTimeout
Dim strUserAgentString
Dim intSslErrorIgnoreFlags
Dim blnEnableRedirects
Dim blnEnableHttpsToHttpRedirects
Dim strHostOverride
Dim strLogin
Dim strPassword
Dim strResponseText
Dim objWinHttp
Dim entry
Dim Base_URL
Dim UpdateTimeStamp

lngTimeout = 59000
strUserAgentString = "http_requester/0.1"
intSslErrorIgnoreFlags = 0 ' 13056: ignore all err, 0: accept no err
blnEnableRedirects = True
blnEnableHttpsToHttpRedirects = True
strHostOverride = ""
strLogin = API_Key & "%" & UN
strPassword = PW
strPostData="<entry xmlns="""">"&vbcrlf&_
"<title type=""text""> </title>"&vbcrlf&_
"<summary type=""text"">Contact</summary>"&vbcrlf&_
"<content type=""application/vnd.ctct+xml"">"&vbcrlf&_
"<Contact xmlns="""">"&vbcrlf&_
"<ContactList id="""&Base_URL&"lists/"&List_ID&""" />"&vbcrlf&_

Response.Write(strPostData & "<hr>")

Set objWinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
objWinHttp.SetTimeouts lngTimeout, lngTimeout, lngTimeout, lngTimeout
objWinHttp.Open strMethod,Base_URL&"contacts"
If strMethod = "POST" Then
objWinHttp.setRequestHeader "Content-type", _
End If
If strHostOverride <> "" Then
objWinHttp.SetRequestHeader "Host", strHostOverride
End If
objWinHttp.Option(0) = strUserAgentString
objWinHttp.Option(4) = intSslErrorIgnoreFlags
objWinHttp.Option(6) = blnEnableRedirects
objWinHttp.Option(12) = blnEnableHttpsToHttpRedirects
If (strLogin <> "") And (strPassword <> "") Then
objWinHttp.SetCredentials strLogin, strPassword, 0
End If 
On Error Resume Next
If Err.Number = 0 Then
If objWinHttp.Status = "200" Then
PostDataToURL = objWinHttp.ResponseText

select case objWinHttp.Status
case "409"
PostDataToURL="2"&vbtab&":Contact Already Exists"
case "201"
PostDataToURL="1"&vbtab&":Contact Successfully added"
case "400"
PostDataToURL="0"&vbtab&":Bad Request. Check Submitted Data: "
case else
PostDataToURL = "0"&vbtab&":" & objWinHttp.Status & " " &objWinHttp.StatusText
end select
End If
PostDataToURL = "Error " & Err.Number & " " & Err.Source & " " & _
End If
On Error GoTo 0
Set objWinHttp = Nothing
End Function 

 The XML generated is:

<entry xmlns="">
<title type="text"> </title>
<summary type="text">Contact</summary>
<content type="application/vnd.ctct+xml">
<Contact xmlns="">
<ContactList id="" />

This all looks pretty simple/straightforward, so I'm assuming the fix must be as well... I'm just using my general login/pass credentials and the API key I was given so... Any help would be greatly appreciated!

CTCT Employee

Re: 403 Forbidden

Hey Jeanne,


The base url may be incorrect. The 403 you should be getting is:

Error 403: Basic Authentication is not available over HTTP

Change your base URL to



Please let me know if this worked for you.

Ryan Davis
Quality Engineer
Occasional Participant

Re: 403 Forbidden

That did the trick / made sense - thank you! One more question, if I change List_ID to "2" it gives me a bad request. I'm guessing the ID is not the same as the "Order" in my list manager. How do I know which list has which ID?

Occasional Participant

Re: 403 Forbidden

I just realized that the list ID is in the URL variable pairs when editing the list / logged into my account. I guess most programmers would be able to discover that :-)

Occasional Participant

Re: 403 Forbidden

Setting the List_ID="3" still gives me a bad request error however... any ideas?

CTCT Employee

Re: 403 Forbidden

Hey Jeanne,


You can get the list id from doing a GET to your list collection.  For ex:{username}/lists

 This will return all your lists with names and ID's. It only shows 50 at a time but inside of lists you will see a next page URI which will show the following 50. 


I would take a look at our rest client as well here.

Let me know if this works for you




Ryan Davis
Quality Engineer