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

Re: Parameter values



Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>


On Mon, 20 Dec 2004 nellestj@xxxxxxx wrote:

How do I pass the value of variable when calling a webservice? Assume OrderNo = '2077736'. If I change the code to 'OrderNumber=2077736', it works fine, but when I change it to 'OrderNumber=' + OrderNo +, I can a return code of 400, which says "Bad Request". Can you help me? Thanks in advance!! :)

As I've already explained, you have to make sure that the data in the URL is properly encoded. You can use HTTPAPI's routines to do this, or you can do it yourself.


Certain characters cannot appear in a URL. This includes spaces, control characters, etc. Other characters have special meaning, such as the plus symbol, the & symbol, etc.

In the specific example that you posted, I'm willing to bet that the problem is spaces in the order number field. You probably use a typical fixed-length RPG field, which will have extra spaces at the end of it. You can use the %trim() BIF to remove them.

However, I strongly recommend that you use an encoding routine to make sure tha parms don't ever contain illegal characters.

EXAMPLE14 demonstrates the URL encoding routines that come with HTTPAPI. In your case, it would be something like:

   Enc = http_url_encoder_new();
   http_url_encoder_addvar_s(Enc: 'OrderNumber': %trimr(OrderNo));
   http_url_encoder_addvar_s(End: 'SequenceNumber: '01');

and so on... check out EXAMPLE14 for a complete example.
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------