QSYS2.HTTP_POST_VERBOSE
Hello Everyone.
I need your help figuring out how to use QSYS2.HTTP_POST_VERBOSE to send a file to Azure blob.
I can use the POSTMAN to upload using that end point using POST method.
Here is my code.
ifsFile_NAME = '/LIB01/text.csv';
ifsFile_NL = %len(ifsFile_NAME);
ifsFile_FO = SQFOVR; // Overwrite any existing file
url = 'https://simple-storage.apps.cloud/api' +
'/v1/repositories/ecsh-ist/documents/ecshTest/cidTestSearch2.txt';
//Extract the IFS file
exec sql
// SELECT GET_CLOB_FROM_FILE(:ifsFile, 1)
SELECT GET_CLOB_FROM_FILE('va967/cidmrg(CIDMRG)', 1)
INTO :data1
FROM SYSIBM.SYSDUMMY1;
//Setup the body
exec sql Set :Req_BODY = json_object(
'document_content' value 'Text',
'document_attribute' value json_object (
'document_name' value :data1,
'description' value 'This is a test file'
),
'folder' value json_object (
'folder_path' value '/ecshTest/'
),
'document_metadata' value json_object (
'metadata_items' value json_array (
json_object('key' value 'DocumentType',
'value' value 'text/plain'),
json_object('key' value 'ClientID',
'value' value '010174132822100',
'index' value '1')
)
)
);
//Setup the header
exec sql Set :Header = json_object(
'header' value ('content-type,multipart/form-data;'
'header' value 'content-length, 3000',
'header' value 'x-channel-id, Branch',
'header' value 'x-originating-appl-code, CAD',
'header' value 'x-country-code, CA',
'header' value 'Host, simple-storage-ist.apps.cloud.bns'
exec sql
select response_http_header, response_message
into :rsp_hdr ,
:rsp_msg
from table(QSYS2.HTTP_POST_VERBOSE(
:url, :Req_BODY, :Header));
I am using that uere, but I am getting 405 error.
Here is the error text (rsp_msg):
{"data":null,"notifications":[{"code":"405","message":"Request method 'POST' not supported. Supported methods:
[GET, PUT, DELETE]","severity":"ERROR","category":null,"description":null,"action":null,"metadata":{},
"uuid":"134a24be-e6cf-4648-8663-69bb0d4c5729","timestamp":"2024-06-28T14:18:36.622072Z","field_name":"HTTP request method"}]}
Here is the composed header value (Header):
{"header":"content-type,multipart/form-data;",
"header":"content-length, 3000","header":"x-channel-id, Branch",
"header":"x-originating-appl-code, CAD",
"header":"x-country-code, CA","header":"Host, simple-storage-ist.apps.cloud.bns"}
Here is the BODY JSON (Req_BODY):
█Ì{"document_content":"Text","document_attribute":{"document
_name":"\u009C011171143347239716285021820103\u00020213482034
45977015339154803115\u0003020177164040528015266170520643K020
349132346648021352172209015\u0002021039135722544015356191057
623\u0002014053131229543021298104025474\u0001021305111955410
019170115624317\u008D020070150912956018011060615714\u0002015
082130228311015006113341028\u0002015082130228311716227124818
847\u009D016141060421696018152165920711\u0002018262114049052
018228101203924\u0002019273172751014021239144838000õ01819008
2104117021347113826725\u0001995170008656970021065120758501\u
0002099348155150336019080122829140\t498310000767008616224011
921828\u0086012065164444589021349200755763\u0086012065164444
589015364100937267\u0001016103134256660021097155629718\u008E
021238121222819021243123009620ä02104222461794401707317421465
8\u0002019039072454899017304220900170\u000102134720211157802
1347203921131\t018040215952050020117015043282\u0002716227110
006543016239180523689=021351152238566021195083542759\u000202
1352113749475021224071000008ï021313194725742017053125922350\
u0001010053160601614017298130931276\t09930813313409502008814
5140328\u0001009264124055430017170135607616","description":"
This is a test file"},"folder":{"folder_path":"/ecshTest/"},
"document_metadata":{"metadata_items":[{"key":"DocumentType"
,"value":"text/plain"},{"key":"ClientID","value":"0101741328
22100","index":"1"}]}}
Any help would be appriciated.
Thanks
Comments
-
Hi,
this is not general IBM i forum, this forum is focused on Xorux's family performance monitoring tools (which is also able to monitor IBM i LPARs).
I would use this one instead: https://community.ibm.com/community/user/power/communities/community-home/digestviewer?CommunityKey=f0246bc4-08f3-43c5-a7f8-b6a64d387894
Howdy, Stranger!
Categories
- 1.6K All Categories
- 43 XORMON NG
- 25 XORMON
- 152 LPAR2RRD
- 13 VMware
- 16 IBM i
- 2 oVirt / RHV
- 4 MS Windows and Hyper-V
- Solaris / OracleVM
- XenServer / Citrix
- Nutanix
- 7 Database
- 2 Cloud
- 10 Kubernetes / OpenShift / Docker
- 122 STOR2RRD
- 19 SAN
- 7 LAN
- 17 IBM
- 3 EMC
- 12 Hitachi
- 5 NetApp
- 15 HPE
- Lenovo
- 1 Huawei
- 1 Dell
- Fujitsu
- 2 DataCore
- INFINIDAT
- 3 Pure Storage
- Oracle