× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello,

Hoping to get some help on this. I found a post about HTTP API’s in QSYS2.

I need to upload a file using URL. Content type of the file is multipart document.

I was able to test the end point using postman and it was successful. It is a 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"}]}}

I am not sure if QSYS2 APIs support multipart documents.

Any help would be appreciated.


Thanks, Sarvan



This e-mail, including any attachments, is confidential and may be privileged and is for the intended recipient(s) only. If received in error, please immediately delete this email and any attachments and contact the sender. Unauthorized copying, use or disclosure of this email or its content or attachments is prohibited. View our full email disclaimer.If you would like to stop receiving commercial electronic messages from The Bank of Nova Scotia, you can unsubscribe.Consultez la traduction en françaisVer la traducción al español

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.