Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unsupported ResponseText encoding: XMLHTTP

Status
Not open for further replies.

travisbrown

Technical User
Dec 31, 2001
1,016
I'm trying to post to a newsletter database (Vertical Response).

When I use the HTML form, it works fine.

When I use the XMLHTTP post it bombs, returns "System does not support the specified encoding". I've never seen this before.

Another tertiary issue - is there a way to append a querystring to an XMLHTTP POST (rather than get)? Looks like the destination server needs a QS string as well as using the posted data.

Any ideas?

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<form method="post" action="[URL unfurl="true"]http://oi.vresp.com?fid=6993457771"[/URL] >
    <label style="color: #333333;">Email Address:</label><br/>
    <input name="email_address" size="15" value="<% = CDBL(DATE()) & "@test.com" %>" />    <input type="submit" value="Join Now" /><br/>
</form>

<%

url = "[URL unfurl="true"]http://oi.vresp.com"[/URL]

response.write XMLHTTPPOST(url,"fid=6993457771&email_address=" & CDBL(DATE()) & "@test.com")

FUNCTION XMLHTTPPOST(url,params)
	url = url '& "?fid=6993457771"
	  Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
	  xml.Open "POST", url, False
	  xml.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
	  xml.Send params
	  Response.ContentType = "text/html"
	  XMLHTTPPOST = xml.responseText
	  Set xml = Nothing	
END FUNCTION
%>
</body>
</html>
 
I should add that the form is posting properly as the data is processed, it's just the response that I don't understand.
 
[1]
>is there a way to append a querystring to an XMLHTTP POST (rather than get)? Looks like the destination server needs a QS string as well as using the posted data.
You can simply attach that querystring to the url and leave it out in the params part. (see below)

[2]
>"System does not support the specified encoding"
As a preliminary test, you can return escaped responsetext see what is in there. Together with the issue in [1], try this see what's got returned.
[tt]
url = "[ignore][/ignore]"

response.write XMLHTTPPOST(url,"email_address=" & CDBL(DATE()) & "@test.com")

FUNCTION XMLHTTPPOST(url,params)
url = url & "?fid=6993457771"
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
xml.Open "POST", url, False
xml.setRequestHeader "Content-Type", "application/x- xml.Send params
'Response.ContentType = "text/html"
XMLHTTPPOST = escape(xml.responseText)
Set xml = Nothing
END FUNCTION
[/tt]
 
You can simply attach that querystring to the url and leave it out in the params part. (see below)

I was trying that (as you see I had it commented out), but it would throw an error: Invalid url. If I removed the qs, it would work. I didn't think that a querystring would be considered a malformed url.

Code:
msxml4.dll error '80072ee5'
The URL is invalid

Escaping the response doesn't work either. I had tried that, and changing the content types to text/plain too. Same response.

Code:
msxml4.dll error 'c00ce56e'
System does not support the specified encoding.



 
You have to ascertain exactly the correct url. Querystring attached directly to the base .com, not much chance to be right.
 
So I guess no way to attach a querystring param using the post method.

It's not an issue in this case, but if, for example, the receiving script used both request.form() and request.querystring rather than the catchall request(), then there'd be an issue.

It's funny that attaching a querystring directly to the input url isn't an issue with the GET method (as opposed to supplying the QS name/values in a separate argument as is apparently required in the POST method)

Any other ideas on the encoding issue? I'm stymied.
 
>So I guess no way to attach a querystring param using the post method.
That's not what I'm saying.
 
>That's not what I'm saying.

I don't understand, then.

>You have to ascertain exactly the correct url. Querystring attached directly to the base .com, not much chance to be right.

Do you mean that you think there needs to be a script name rather than relying on a default document?

This is what I'm posting the working html form to:

Find the right document and use something like this?
 
Well check you url ([ignore][/ignore]). I think you think it is correct. I advance it may not. With all the arguments in the vacuum, there would not be any point for me insisting.
 
Sorry, tsuji. I appreciate the help, adn maybe I'm completely misunderstanding you, but what do you see wrong with this url? It goes where I want it to go.


It does work in both the function and the html form action (though needs the parameter fid in either a post or get to return useful data - and as a qs in a xmlhttp post, it's a problem).

 
What would be default page the site actually receiving the post, such as .../index.asp or ./default.asp? If it is a webservice, I would not be surprisef that there won't be any page like .asp or .php or .cgi or their .net ramifications, it could be just a virtual-directory-like url. But a look like just that period?... I would be somewhat surprised.
 
I agree that there is a default page somewhere. I've never needed it with GET submissions - something like has always worked fine, so I'd assumed that it would work with POST as well.

I'll try and see if adding a default doc helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top