[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: 400 Bad Request

Hi Gerald,

Welcome to the wonderful world of HTTPAPI. 

The form of the string that works is a GET. You are using a POST. Depending on what you are getting back will depend on what to do next. If the result is just a name and you would like to stick it in a variable, use something like discussed in this post: 


The content type is most likely not 'application/x-www-form-urlencoded' but probably 'text/html'. Using get_raw, you don't have to pass it a particular content-type (as shown in the example code in the post above).

If you want to use the webform support with a get, do it this way (from EXAMPLE9):
form = webform_open();                                      
webform_setVar(form: 'url': inputURL);                      
webform_setVar(form: 'ret': %trimr(%subst(outputFormat:2)));
uri = 'http://html2pdf.biz/api?' + webform_getData(form);   

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Gerald Magnuson
Sent: Monday, March 11, 2013 9:54 AM
To: HTTPAPI and FTPAPI Projects (ftpapi@xxxxxxxxxxxxxxxxxxxxxx)
Subject: 400 Bad Request

I tried to copy from a working program, but I must have messed up somewhere..

HERE IS THE STRING THAT WORKS, when I try it in a browser:

here is my code:


Form = WEBFORM_open;

If P1_UsrID <> *blanks ;
  WEBFORM_SetVar(Form: 'input_name': %trim(P1_UsrID) );
EndIF ;

WEBFORM_postData( Form : myPointer
: dataSize );

'http://knapportal-test.knapheide.com/modules' +
myPointer: dataSize :
1: %paddr('INCOMING')
: 'application/x-www-form-urlencoded' );

if rc <> 1;
         *** rc comes back as 400...

Here is data from the error log:
HTTPAPI Ver 1.23 released 2008-04-24
OS/400 Ver V7R1M0

New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 4
DNS resolver retry  : 4
DNS resolver options: x'00000136'
DNS default domain: knapheide.com
DNS server found:
DNS server found:
http_persist_post(): entered
http_long_ParseURL(): entered
do_post(): entered
POST /modules/getboss/getusersboss.php HTTP/1.1
Host: knapportal-test.knapheide.com
User-Agent:   http-api/1.24
Content-Type:   application/x-www-form-urlencoded
Expect: 100-continue
Content-Length: 20

recvresp(): entered
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 11 Mar 2013 14:37:36 GMT
Connection: close
Content-Length: 311

SetError() #13: HTTP/1.1 400 Bad Request
recvdoc parms: identity 311
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd";>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>

SetError() #13: HTTP/1.1 400 Bad Request
http_close(): entered

This is the FTPAPI mailing list.  To unsubscribe, please go to: