Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Previous revision
systools_http [2019/01/07 16:26]
systools_http [2021/04/19 20:10] (current)
mihael
Line 1: Line 1:
 +====== SYSTOOLS HTTP SQL Functions ======
  
 +For some time now you can make HTTP requests with SQL via some UDFs. But there are some things to consider when using them.
 +
 +
 +===== CCSID =====
 +You may encounter a character conversion error when executing your program though the SQL perfectly works in your SQL editor of choice. This is due to some assumptions made by the compiler.
 +
 +For example it assumes that the host variables are the same CCSID as the job CCSID (in my case no matter how I defined the host variables, even the keyword ''ccsid'' did not help).
 +
 +So when compiling your program you should set the correct CCSID at the job.
 +
 +    CHGJOB CCSID(273)
 +
 +
 +===== HTTP Header =====
 +
 +The default headers are not always what you want to use so you should define your own.
 +
 +<sxh sql>
 +SELECT * FROM (Values(
 +    SYSTOOLS.HTTPGETCLOB( 
 +        'http://localhost/book?isbn=1234567890',
 +        '<httpHeader><header name="Accept" value="application/xml"/><header name="Content-Type" value="application/xml"/></httpHeader>')));
 +</sxh>
 +
 +For VERBOSE functions you can also add "includeErrorMsg=true" as and XML attribute to "httpHeader" to get the HTTP message body when a HTTP response is not ok else the message body will be empty.
 +
 +===== Resources =====
 +
 +  * [[https://www.ibm.com/developerworks/community/forums/html/topic?id=73917ac0-b6cf-4728-80f6-b40db4be260e | IBM DB2 Forum : SQLSTATE 57017 in RPG using SQL UDF]]
 +  * [[https://www.mcpressonline.com/programming/web-languages/techtip-db2-for-i-http-functions-part-2-request-and-response-header-fields | McPressOnline : Techtip DB2 for i HTTP functions]]
 +
 +{{tag>devel ibm sql rpg xml}}