{"id":5683,"date":"2024-03-08T21:31:08","date_gmt":"2024-03-08T20:31:08","guid":{"rendered":"https:\/\/gpmfactory.com\/?p=5683"},"modified":"2024-03-08T21:31:08","modified_gmt":"2024-03-08T20:31:08","slug":"post-both-an-image-and-parameters-to-an-ords-rest-service","status":"publish","type":"post","link":"https:\/\/gpmfactory.com\/index.php\/2024\/03\/08\/post-both-an-image-and-parameters-to-an-ords-rest-service\/","title":{"rendered":"POST both an image and parameters to an ORDS REST service"},"content":{"rendered":"\n<p>Pour envoyer une image avec des attributs, voici deux techniques qui fonctionnent\u00a0sur Oracle ORDS (test\u00e9 sur la version 23.4) <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Utiliser des\u00a0<strong>query parameters<\/strong>\n<ul class=\"wp-block-list\">\n<li>Dans le handler\n<ul class=\"wp-block-list\">\n<li>\u00e9crire une requ\u00eate\u00a0du type <br><code>insert into XXX (id, name, photo) values (:id, :lib, :BODY);<\/code><\/li>\n\n\n\n<li>Ne d\u00e9clarer aucun param\u00e8tres<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Dans Postman ou Curl:\n<ul class=\"wp-block-list\">\n<li>indiquer un content-type =&nbsp;image\/jpg&nbsp;<\/li>\n\n\n\n<li>et d\u00e9clarer deux\u00a0<em>query parameters<\/em>\u00a0:\u00a0id\u00a0et\u00a0name<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Utiliser des\u00a0<strong>variables de Header<\/strong>\n<ul class=\"wp-block-list\">\n<li>Dans le handler, \n<ul class=\"wp-block-list\">\n<li>\u00e9crire une requ\u00eate\u00a0du type <br><code>insert into XXX (id, name, photo) values (:id, :lib, :BODY);<\/code><\/li>\n\n\n\n<li>D\u00e9clarer deux param\u00e8tres de type Header:&nbsp;id&nbsp;et&nbsp;name<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Dans Postman ou Curl\n<ul class=\"wp-block-list\">\n<li>indiquer un content-type = &lsquo;Image\/jpeg&rsquo;<\/li>\n\n\n\n<li>et ajouter deux autres variables de header:\u00a0id\u00a0et\u00a0lib. (Attention \u00e0 ne pas utiliser\u00a0un nom r\u00e9serv\u00e9 de variable )<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Il doit y  avoir, peut-\u00eatre, une autre approche qui consiste \u00e0 utiliser du\u00a0<em>multi<\/em>part\u00a0content Type et qui revient \u00e0 indiquer un body (=payload) de type\u00a0<em>image<\/em>\u00a0combin\u00e9 un autre de type json structur\u00e9 ainsi:\u00a0{\u00ab\u00a0id\u00a0\u00bb:\u00a0\u00bbxxx\u00a0\u00bb, \u00ab\u00a0name\u00a0\u00bb,\u00a0\u00bbnnnnn\u00a0\u00bb}. Dans ce troisi\u00e8me cas, les attributs sont lus de fa\u00e7on implicite dans le code du handler \u00e0 partir de leur noms (:id\u00a0et :name) ou bien extraits depuis le param\u00e8tre implicite\u00a0:BODY_TEXT. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pour envoyer une image avec des attributs, voici deux techniques qui fonctionnent\u00a0sur Oracle ORDS (test\u00e9 sur la version 23.4) Il doit y avoir, peut-\u00eatre,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"ppma_author":[150],"class_list":["post-5683","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"authors":[{"term_id":150,"user_id":1,"is_guest":0,"slug":"admin8700","display_name":"Patrick","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/209d5ed69b74d288390621ab4c1d3773?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts\/5683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/comments?post=5683"}],"version-history":[{"count":2,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts\/5683\/revisions"}],"predecessor-version":[{"id":5685,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts\/5683\/revisions\/5685"}],"wp:attachment":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/media?parent=5683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/categories?post=5683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/tags?post=5683"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/ppma_author?post=5683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}