lizardbreath
Board Regular
- Joined
- Feb 23, 2012
- Messages
- 54
Hi There,
I have code that I created that sends a post to a CRM to create a record. After sending the post, I need to consume data from the basic XML Response which is where I am stuck on.
Here is an example of the code to post the data, I had to strip out the actual URL due to security reasons(Bolded section).
Sub CreateRecord()
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "POST", "FakeWebsite", False
.SetRequestHeader "content-type", "application/x-www-form-urlencoded; charset=UTF-8"
.SetRequestHeader "user-agent", "user-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64)"
.Send "First_name=Bob"
MsgBox .ResponseText
End With
End Sub
When I send this request, it will respond with an XML that looks like this below. I need to extract out the LeadId value of "6881061" and the result value of "Success" and put it into two difference cells F2 & G2
<?xml version="1.0" encoding="UTF-8"?>
<ImportResults>
<ImportResult refId="" leadId="6881061" result="Success" message="" />
</ImportResults>
I have code that I created that sends a post to a CRM to create a record. After sending the post, I need to consume data from the basic XML Response which is where I am stuck on.
Here is an example of the code to post the data, I had to strip out the actual URL due to security reasons(Bolded section).
Sub CreateRecord()
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "POST", "FakeWebsite", False
.SetRequestHeader "content-type", "application/x-www-form-urlencoded; charset=UTF-8"
.SetRequestHeader "user-agent", "user-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64)"
.Send "First_name=Bob"
MsgBox .ResponseText
End With
End Sub
When I send this request, it will respond with an XML that looks like this below. I need to extract out the LeadId value of "6881061" and the result value of "Success" and put it into two difference cells F2 & G2
<?xml version="1.0" encoding="UTF-8"?>
<ImportResults>
<ImportResult refId="" leadId="6881061" result="Success" message="" />
</ImportResults>