terrybuck9
asked on
I need to Integrate Hubspot into my .asp application but don't know how to POST
Hi
I am a total beginner in Hubspot and JSON
My application has a landing page (.asp) where I have gathered all my client details and I now have to update Hubspot.
Looking at their manuals I guess I need to put all my variables in a <script> </script> like below:
<script>
{
"properties": [
{
"property": "email",
"value": "test@hubspot.com"
},
{
"property": "firstname",
"value": "HubSpot"
}
]
}
</script>
firstly is this correct?
then I need to do a post with a command like:
Example POST URL:
https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/testingapis@hubspot.com/?hapikey=demo
secondly, how do I do this post in my .asp file to send the data?
Please can you help as I don't know where to start? as Hubspot don't seem to want to get involved in any integrations.
Thanks Terry
I am a total beginner in Hubspot and JSON
My application has a landing page (.asp) where I have gathered all my client details and I now have to update Hubspot.
Looking at their manuals I guess I need to put all my variables in a <script> </script> like below:
<script>
{
"properties": [
{
"property": "email",
"value": "test@hubspot.com"
},
{
"property": "firstname",
"value": "HubSpot"
}
]
}
</script>
firstly is this correct?
then I need to do a post with a command like:
Example POST URL:
https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/testingapis@hubspot.com/?hapikey=demo
secondly, how do I do this post in my .asp file to send the data?
Please can you help as I don't know where to start? as Hubspot don't seem to want to get involved in any integrations.
Thanks Terry
ASKER
Hi
Yes I have seen this, but I am not a php programmer either.
I can do it in either as long as it can sit on my .asp page.
Your advice would be great. But I do need to know syntax and where to put it, and how to call it.
Thanks Terry
Yes I have seen this, but I am not a php programmer either.
I can do it in either as long as it can sit on my .asp page.
Your advice would be great. But I do need to know syntax and where to put it, and how to call it.
Thanks Terry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Big Monty
thanks for your help.
I don't get the first bit, as I think I need to "send it server side". As I have various .asp pages that gather information in forms and land on my last page.
so if I insert my code in my .asp page like this:
<%
PostData = "<
{
"properties": [
{
"property": "email",
"value": "test@hubspot.com"
},
{
"property": "firstname",
"value": "HubSpot"
}
]
}
>"
Set ServerXmlHttp = Server.CreateObject("MSXML 2.ServerXM LHTTP.6.0" )
ServerXmlHttp.open "POST", "https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/testingapis@hubspot.com/?hapikey=demo"
ServerXmlHttp.setRequestHe ader "Content-Type", "application/json"
ServerXmlHttp.setRequestHe ader "Content-Length", Len( PostData )
ServerXmlHttp.send PostData
%>
Please let me know if syntax correct?
then
<%
If ServerXmlHttp.status = 200 Then
TextResponse = ServerXmlHttp.responseText
XMLResponse = ServerXmlHttp.responseXML
StreamResponse = ServerXmlHttp.responseStre am
Else
' Handle missing response or other errors here
End If
Set ServerXmlHttp = Nothing
%>
then the response will be in StreamResponse if success?
I know this is all basic stuff, but It just hasn't clicked yet.
Thanks Terry
thanks for your help.
I don't get the first bit, as I think I need to "send it server side". As I have various .asp pages that gather information in forms and land on my last page.
so if I insert my code in my .asp page like this:
<%
PostData = "<
{
"properties": [
{
"property": "email",
"value": "test@hubspot.com"
},
{
"property": "firstname",
"value": "HubSpot"
}
]
}
>"
Set ServerXmlHttp = Server.CreateObject("MSXML
ServerXmlHttp.open "POST", "https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/testingapis@hubspot.com/?hapikey=demo"
ServerXmlHttp.setRequestHe
ServerXmlHttp.setRequestHe
ServerXmlHttp.send PostData
%>
Please let me know if syntax correct?
then
<%
If ServerXmlHttp.status = 200 Then
TextResponse = ServerXmlHttp.responseText
XMLResponse = ServerXmlHttp.responseXML
StreamResponse = ServerXmlHttp.responseStre
Else
' Handle missing response or other errors here
End If
Set ServerXmlHttp = Nothing
%>
then the response will be in StreamResponse if success?
I know this is all basic stuff, but It just hasn't clicked yet.
Thanks Terry
ASKER
Hi Big Monty
I have been messing and I did this, and I get a 400 response.
<%
PostData = "<{""properties"": [{""property"": ""email"",""value"": ""test@hubspot.com""},{""p roperty"": ""firstname"",""value"": ""HubSpot""}]}>"
Set ServerXmlHttp = Server.CreateObject("MSXML 2.ServerXM LHTTP.6.0" )
ServerXmlHttp.open "POST", "https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/terry@hubspot.com/?hapikey=demo"
ServerXmlHttp.setRequestHe ader "Content-Type", "application/json"
ServerXmlHttp.setRequestHe ader "Content-Length", Len( PostData )
ServerXmlHttp.send PostData
%>
<%
If ServerXmlHttp.status = 200 Then
TextResponse = ServerXmlHttp.responseText
XMLResponse = ServerXmlHttp.responseXML
StreamResponse = ServerXmlHttp.responseStre am
Else
' Handle missing response or other errors here
response.Write (ServerXmlHttp.status)
End If
Set ServerXmlHttp = Nothing
response.Write (TextResponse)
%>
I have been messing and I did this, and I get a 400 response.
<%
PostData = "<{""properties"": [{""property"": ""email"",""value"": ""test@hubspot.com""},{""p
Set ServerXmlHttp = Server.CreateObject("MSXML
ServerXmlHttp.open "POST", "https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/terry@hubspot.com/?hapikey=demo"
ServerXmlHttp.setRequestHe
ServerXmlHttp.setRequestHe
ServerXmlHttp.send PostData
%>
<%
If ServerXmlHttp.status = 200 Then
TextResponse = ServerXmlHttp.responseText
XMLResponse = ServerXmlHttp.responseXML
StreamResponse = ServerXmlHttp.responseStre
Else
' Handle missing response or other errors here
response.Write (ServerXmlHttp.status)
End If
Set ServerXmlHttp = Nothing
response.Write (TextResponse)
%>
your syntax looks good on your latest post. if you're getting a 400 response, it means that attempt to send the data was good, but failed, either due to a bad URL or there was an access issue. Using the link directly, it came back with no response, so I would work first on getting the right URL in place and trying to access it directly in the browser. once you have that figured it, you should be able to plug it into your page
ASKER
Hi
Great thanks, sounds like I am on the right track.
I changed data to:
PostData = "{""properties"": [{""property"": ""email"",""value"": ""test@hubspot.com""},{""p roperty"": ""firstname"",""value"": ""HubSpot""}]}"
taking out the < and >.
now I am getting a 409?
Terry
Great thanks, sounds like I am on the right track.
I changed data to:
PostData = "{""properties"": [{""property"": ""email"",""value"": ""test@hubspot.com""},{""p
taking out the < and >.
now I am getting a 409?
Terry
ASKER
Hi Big Monty
I think I have cracked it with your help.
I now get a response:
{"vid":4027074,"isNew":tru e}
Which means it works.
thanks very much, you helped me get off the ground.
Thanks Again
Terry
I think I have cracked it with your help.
I now get a response:
{"vid":4027074,"isNew":tru
Which means it works.
thanks very much, you helped me get off the ground.
Thanks Again
Terry
always validate your JSON (which this is) with an online validator, such as https://jsonformatter.curiousconcept.com/. To do so, simply do:
Response.Write PostData
Response.End
now run the page and you'll get the JSON string. Copy and paste that into the URL above and it'll tell you if it's valid or not.
as for the 409 response, I'm not sure. It's defined as a conflict, but I'm unsure of what that means...
Response.Write PostData
Response.End
now run the page and you'll get the JSON string. Copy and paste that into the URL above and it'll tell you if it's valid or not.
as for the 409 response, I'm not sure. It's defined as a conflict, but I'm unsure of what that means...
glad i could help :)
ASKER
Works a treat, used the server side option.
Thanks Terry
Thanks Terry
http://developers.hubspot.com/docs/methods/contacts/contacts-overview
try click on the sub-menu items and they got posted some examples there (provided in php).
do you need to get it done in ASP?