Skip to main content

Hi all

I'm trying to create an HTTP request following this:

POST /quiter/qae/... HTTP/1.1
Host: ...:8000
Content-Length: 592
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="attachmentMetadata"
{"referenciaDms" : "...","ficheroDms" : "...","usuario" : "quiter","descripcion" : "prueba","workspace" : "quiter"}

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="/u2/quiter/DATOS/qsac_quiter.png"
Content-Type: image/png

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--

--

My BASIC code is like this

NOM.SUB='RU2'

URL.SERVICIO='http://...:8000/quiter/qae/...'

TIPO.LLAMADA='POST:multipart/form-data'

RESPUESTA=setHTTPDefault('VERSION','1.1')

RESPUESTA=createRequest(URL.SERVICIO,TIPO.LLAMADA,HTTP.HANDLE)

ADDPARAM='{"referenciaDms" : "85818","ficheroDms" : "FMVEHPT","usuario" : "quiter","descripcion" : "prueba","workspace" : "quiter"}'
RESPUESTA=addRequestParameter(HTTP.HANDLE,'attachmentMetadata',ADDPARAM,'multipart/form-data')
RESPUESTA=addRequestParameter(HTTP.HANDLE,'file','/u2/quiter/DATOS/qsac_quiter.png','multipart/form-data')

TIME.OUT=10
DATOS.POST=''
RESPUESTA=submitRequest(HTTP.HANDLE,TIME.OUT,DATOS.POST,CABECERA.RESPUESTA,DATOS.RESPUESTA,HTTP.STATUS)
CRT NOM.SUB:' HTTP.STATUS [':HTTP.STATUS:'] ':TIME()
CRT NOM.SUB:' RESPUESTA FINAL [':RESPUESTA:'] ':TIME()
CRT NOM.SUB:' DATOS.RESPUESTA [':DATOS.RESPUESTA:'] ':TIME()

And the response is telling me that the data is not arriving on the expected place

RU2 HTTP.STATUS [422²Unprocessable Entity] 35816.43
RU2 RESPUESTA FINAL [0] 35816.43
RU2 DATOS.RESPUESTA[
	{
        "detail": [{
                "type": "missing",
                "loc": ["body", "file"],
                "msg": "Field required",
                "input": null,
                "url": "https://errors.pydantic.dev/2.4/v/missing"
            }, {
                "type": "missing",
                "loc": ["body", "attachmentMetadata"],
                "msg": "Field required",
                "input": null,
                "url": "https://errors.pydantic.dev/2.4/v/missing"
            }
        ]
    }
]35816.43

Is there a way to see what is the raw HTTP request that I'm forming, to see what info is missing?

Am I overlooking something?



------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------

Hi all

I'm trying to create an HTTP request following this:

POST /quiter/qae/... HTTP/1.1
Host: ...:8000
Content-Length: 592
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="attachmentMetadata"
{"referenciaDms" : "...","ficheroDms" : "...","usuario" : "quiter","descripcion" : "prueba","workspace" : "quiter"}

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="/u2/quiter/DATOS/qsac_quiter.png"
Content-Type: image/png

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--

--

My BASIC code is like this

NOM.SUB='RU2'

URL.SERVICIO='http://...:8000/quiter/qae/...'

TIPO.LLAMADA='POST:multipart/form-data'

RESPUESTA=setHTTPDefault('VERSION','1.1')

RESPUESTA=createRequest(URL.SERVICIO,TIPO.LLAMADA,HTTP.HANDLE)

ADDPARAM='{"referenciaDms" : "85818","ficheroDms" : "FMVEHPT","usuario" : "quiter","descripcion" : "prueba","workspace" : "quiter"}'
RESPUESTA=addRequestParameter(HTTP.HANDLE,'attachmentMetadata',ADDPARAM,'multipart/form-data')
RESPUESTA=addRequestParameter(HTTP.HANDLE,'file','/u2/quiter/DATOS/qsac_quiter.png','multipart/form-data')

TIME.OUT=10
DATOS.POST=''
RESPUESTA=submitRequest(HTTP.HANDLE,TIME.OUT,DATOS.POST,CABECERA.RESPUESTA,DATOS.RESPUESTA,HTTP.STATUS)
CRT NOM.SUB:' HTTP.STATUS [':HTTP.STATUS:'] ':TIME()
CRT NOM.SUB:' RESPUESTA FINAL [':RESPUESTA:'] ':TIME()
CRT NOM.SUB:' DATOS.RESPUESTA [':DATOS.RESPUESTA:'] ':TIME()

And the response is telling me that the data is not arriving on the expected place

RU2 HTTP.STATUS [422²Unprocessable Entity] 35816.43
RU2 RESPUESTA FINAL [0] 35816.43
RU2 DATOS.RESPUESTA[
	{
        "detail": [{
                "type": "missing",
                "loc": ["body", "file"],
                "msg": "Field required",
                "input": null,
                "url": "https://errors.pydantic.dev/2.4/v/missing"
            }, {
                "type": "missing",
                "loc": ["body", "attachmentMetadata"],
                "msg": "Field required",
                "input": null,
                "url": "https://errors.pydantic.dev/2.4/v/missing"
            }
        ]
    }
]35816.43

Is there a way to see what is the raw HTTP request that I'm forming, to see what info is missing?

Am I overlooking something?



------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------

By the way, this is how I'm doint it with Python

import requests

url = 'http://10.3.22.39:8000/quiter/qae/...'
files = {
    'file': ('quiter.png', open('quiter.png', 'rb'), 'image/png'),
    'attachmentMetadata': (None, '{"mimetype": "image/png","ficheroDms": "...","referenciaDms": "...",'
                          '"usuario": "...","descripcion": "quiter.png","versionobj": 400,'
                          '"workspace": "quiter","fechaUltimaModificacion": "2023-11-21T10:40:15.407Z",'
                          '"OrdenFoto": 1,"PublicarFoto": true,"EsFoto": true}')
}
r = requests.Request('POST', url, files=files)
p = r.prepare()
s = requests.Session()
t = s.send(p)


------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------

Hi all

I'm trying to create an HTTP request following this:

POST /quiter/qae/... HTTP/1.1
Host: ...:8000
Content-Length: 592
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="attachmentMetadata"
{"referenciaDms" : "...","ficheroDms" : "...","usuario" : "quiter","descripcion" : "prueba","workspace" : "quiter"}

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="/u2/quiter/DATOS/qsac_quiter.png"
Content-Type: image/png

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--

--

My BASIC code is like this

NOM.SUB='RU2'

URL.SERVICIO='http://...:8000/quiter/qae/...'

TIPO.LLAMADA='POST:multipart/form-data'

RESPUESTA=setHTTPDefault('VERSION','1.1')

RESPUESTA=createRequest(URL.SERVICIO,TIPO.LLAMADA,HTTP.HANDLE)

ADDPARAM='{"referenciaDms" : "85818","ficheroDms" : "FMVEHPT","usuario" : "quiter","descripcion" : "prueba","workspace" : "quiter"}'
RESPUESTA=addRequestParameter(HTTP.HANDLE,'attachmentMetadata',ADDPARAM,'multipart/form-data')
RESPUESTA=addRequestParameter(HTTP.HANDLE,'file','/u2/quiter/DATOS/qsac_quiter.png','multipart/form-data')

TIME.OUT=10
DATOS.POST=''
RESPUESTA=submitRequest(HTTP.HANDLE,TIME.OUT,DATOS.POST,CABECERA.RESPUESTA,DATOS.RESPUESTA,HTTP.STATUS)
CRT NOM.SUB:' HTTP.STATUS [':HTTP.STATUS:'] ':TIME()
CRT NOM.SUB:' RESPUESTA FINAL [':RESPUESTA:'] ':TIME()
CRT NOM.SUB:' DATOS.RESPUESTA [':DATOS.RESPUESTA:'] ':TIME()

And the response is telling me that the data is not arriving on the expected place

RU2 HTTP.STATUS [422²Unprocessable Entity] 35816.43
RU2 RESPUESTA FINAL [0] 35816.43
RU2 DATOS.RESPUESTA[
	{
        "detail": [{
                "type": "missing",
                "loc": ["body", "file"],
                "msg": "Field required",
                "input": null,
                "url": "https://errors.pydantic.dev/2.4/v/missing"
            }, {
                "type": "missing",
                "loc": ["body", "attachmentMetadata"],
                "msg": "Field required",
                "input": null,
                "url": "https://errors.pydantic.dev/2.4/v/missing"
            }
        ]
    }
]35816.43

Is there a way to see what is the raw HTTP request that I'm forming, to see what info is missing?

Am I overlooking something?



------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------

Hector,

If you turn on protocollogging, and run the program it will provide more information about what is going on.

I believe the issue is with the line

RESPUESTA=addRequestParameter(HTTP.HANDLE,'file','/u2/quiter/DATOS/qsac_quiter.png','multipart/form-data')

I do not think that line is doing what you think it is doing.

Is there a reason you are not using the Python code that is working?



------------------------------
Mike Rajkowski
MultiValue Product Evangelist
Rocket Internal - All Brands
US
------------------------------

Hector,

If you turn on protocollogging, and run the program it will provide more information about what is going on.

I believe the issue is with the line

RESPUESTA=addRequestParameter(HTTP.HANDLE,'file','/u2/quiter/DATOS/qsac_quiter.png','multipart/form-data')

I do not think that line is doing what you think it is doing.

Is there a reason you are not using the Python code that is working?



------------------------------
Mike Rajkowski
MultiValue Product Evangelist
Rocket Internal - All Brands
US
------------------------------

Hi Mike


I can't use the Python code because not all the clients that will use this project have a Python license. It was just a workaround.

I do not think that line is doing what you think it is doing.

I guess, I'm a total begginer to Universe BASIC, or just BASIC. 

I guess I should pass a file descriptor instead of a path?



------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------

Hi Mike


I can't use the Python code because not all the clients that will use this project have a Python license. It was just a workaround.

I do not think that line is doing what you think it is doing.

I guess, I'm a total begginer to Universe BASIC, or just BASIC. 

I guess I should pass a file descriptor instead of a path?



------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------

I tried reading the PNG file using READBLK:

   OPENSEQ '/u2/quiter/POSVENTA5/DATOS/qsac_quiter.png' TO PNG THEN CRT 'PNG OK' ELSE CRT 'PNG KO'; GOTO 90
   ALLREG = ''
   LOOP WHILE READBLK REG FROM PNG, 1024 DO
      ALLREG=ALLREG:REG
   REPEAT
   CLOSESEQ PNG

   RESPUESTA=addRequestParameter(HTTP.HANDLE,'file',ALLREG,'multipart/form-data')
   CRT NOM.SUB:'addRequestParameter RESPUESTA [':RESPUESTA:'] ':TIME()

In the protocollog I can see this:

12/21/2023 11:33:27 [ 31722 31721 ] addRequestParameter ... host=...,parm=attachmentMetadata:{"mimetype": "text/plain", "referenciaDms" : "...","ficheroDms" : "...","usuario" : "...","descripcion" : "prueba","workspace" : "quiter"},type=multipart/form-data
12/21/2023 11:33:27 [ 31722 31721 ] addRequestParameter: added attachmentMetadata={"mimetype": "text/plain", "referenciaDms" : "85818","ficheroDms" : "...","usuario" : "...","descripcion" : "prueba","workspace" : "quiter"}, type multipart/form-data

12/21/2023 11:33:27 [ 31722 31721 ] addRequestParameter ... host=...,parm=file: PNG

,type=multipart/form-data
12/21/2023 11:33:27 [ 31722 31721 ] addRequestParameter: added file= PNG

, type multipart/form-data

12/21/2023 11:33:27 [ 31722 31721 ] submitRequest ... Var a819d0: host=...,timeout=10

In the line " added file= PNG"  appears to be a PNG file header



------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------

I tried reading the PNG file using READBLK:

   OPENSEQ '/u2/quiter/POSVENTA5/DATOS/qsac_quiter.png' TO PNG THEN CRT 'PNG OK' ELSE CRT 'PNG KO'; GOTO 90
   ALLREG = ''
   LOOP WHILE READBLK REG FROM PNG, 1024 DO
      ALLREG=ALLREG:REG
   REPEAT
   CLOSESEQ PNG

   RESPUESTA=addRequestParameter(HTTP.HANDLE,'file',ALLREG,'multipart/form-data')
   CRT NOM.SUB:'addRequestParameter RESPUESTA [':RESPUESTA:'] ':TIME()

In the protocollog I can see this:

12/21/2023 11:33:27 [ 31722 31721 ] addRequestParameter ... host=...,parm=attachmentMetadata:{"mimetype": "text/plain", "referenciaDms" : "...","ficheroDms" : "...","usuario" : "...","descripcion" : "prueba","workspace" : "quiter"},type=multipart/form-data
12/21/2023 11:33:27 [ 31722 31721 ] addRequestParameter: added attachmentMetadata={"mimetype": "text/plain", "referenciaDms" : "85818","ficheroDms" : "...","usuario" : "...","descripcion" : "prueba","workspace" : "quiter"}, type multipart/form-data

12/21/2023 11:33:27 [ 31722 31721 ] addRequestParameter ... host=...,parm=file: PNG

,type=multipart/form-data
12/21/2023 11:33:27 [ 31722 31721 ] addRequestParameter: added file= PNG

, type multipart/form-data

12/21/2023 11:33:27 [ 31722 31721 ] submitRequest ... Var a819d0: host=...,timeout=10

In the line " added file= PNG"  appears to be a PNG file header



------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------

I've seen this line in the log

12/21/2023 12:32:20 [ 31722 31721 ] submitRequest ... Var a819d0: host=10.3.22.39:8000,timeout=10
12/21/2023 12:32:20 [ 31722 31721 ] Assembled Request (body omitted,length=100511):

Is there a way to show the HTTP body on the log?



------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------

Hector,

If you turn on protocollogging, and run the program it will provide more information about what is going on.

I believe the issue is with the line

RESPUESTA=addRequestParameter(HTTP.HANDLE,'file','/u2/quiter/DATOS/qsac_quiter.png','multipart/form-data')

I do not think that line is doing what you think it is doing.

Is there a reason you are not using the Python code that is working?



------------------------------
Mike Rajkowski
MultiValue Product Evangelist
Rocket Internal - All Brands
US
------------------------------

Elaborating on this.

Instead of a PNG file now I'm using a small text file:

TEST 1
TEST 2
TEST 3

I can see the file data in the log

12/21/2023 14:01:34 [ 38113 38112 ] addRequestParameter ... host=...,parm=qsac_quiter.txt:TEST1
TEST2
TEST3,type=multipart/form-data
12/21/2023 14:01:34 [ 38113 38112 ] addRequestParameter: added qsac_quiter.txt=TEST1
TEST2
TEST3, type multipart/form-data
TES
12/21/2023 14:01:34 [ 38113 38112 ] submitRequest ... Var 15a9bf0: host=...,timeout=10
12/21/2023 14:01:34 [ 38113 38112 ] Assembled Request (body omitted,length=448):
POST /quiter/qae... HTTP/1.1
Date: Thu, 21 Dec 2023 13:01:34 GMT
Host: ...
User-Agent: Rocket UniVerse 11.x
Content-Type: multipart/form-data; boundary="----SxYr:tSOp-qHyX_38113_1703163694"
Content-Length: 448

But the message is not properly assembled, because I'm getting an error from the server.

Sending the same file via cURL:

POST /quiter/qae/.../... HTTP/1.1
Host: ...
User-Agent: curl/8.0.1
Accept: */*
Content-Length: 591
Content-Type: multipart/form-data; boundary=------------------------02ade7b52f87250d

--------------------------02ade7b52f87250d
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain

TEST1
TEST2
TEST3
--------------------------02ade7b52f87250d
Content-Disposition: form-data; name="attachmentMetadata"

{"mimetype": "text/plain","ficheroDms": "...","referenciaDms": "...","usuario": "...","descripcion": "Fichero image (16).png","versionobj": 400,"workspace": "quiter","fechaUltimaModificacion": "2023-11-21T10:40:15.407Z","OrdenFoto": 1,"PublicarFoto": true,"EsFoto": true}
--------------------------02ade7b52f87250d--
HTTP/1.1 200 OK
date: Thu, 21 Dec 2023 13:49:37 GMT
server: uvicorn
content-length: 26
content-type: application/json

"65844272189bff000951843b"


------------------------------
Héctor Cortiguera
Quiter Servicios Informaticos SL
------------------------------