|
El Foro es mi casa
|
21.08.2026 18:08
|
|
Posts: 365
|
|
Enviados: 252
|
|
Recibidos: 243
|
|
Citación del post de Fito
|
❞
Código COBOL:
WORKING-STORAGE SECTION. 01 wsend. 02 pic x(115) value '{"000001":{"k":"1","rk":"1","b":"0","d":"CREMOSO LA LACTEO","i":"","n":"CREMOSO LA LACTEO","ld":"CREMOSO LA LACTEO"'. 02 pic x(115) value ',"nc":"0","fa":"0","dum":"UN","v":{"a":"21","f":false},"um":{"UN":{"e":"1","k":"UN","n":"UNIDAD"}}}}'. PROCEDURE DIVISION. #include "copys\declara-com.cpy". comienzo. invoke COM "CREATE-OBJECT" using winhttp returning oWS. invoke oWS "OPEN" using metodo arti-alta modo. move "Authorization" to RH1. move credenciales to RH2. invoke oWS "setRequestHeader" using RH1 RH2. invoke grdLista "AddItem" using credenciales. move "Content-Type" to RH1. move "application/json" to RH2. invoke oWS "setRequestHeader" using RH1 RH2. invoke oWS "send" using wsend. invoke oWS "get-Responsetext" returning respuesta. set oWS to null. invoke grdLista "AddItem" using respuesta. exit program.
Acá trato de enviar el json de artículos. En esta prueba que les muestro el json lo cargo en una variable, pero la idea es poder enviar el archivo.
Si lo hago con Postman no tengo problemas, pero no sé traducir al cobol eso
Ahí les paso la imagen de pantalla del Postman.
En el body, selecciono binary y me pide el archivo. Ahora cómo hacerlo en Cobol no pude...
Saludos
Fito...
|
Podrias probar algo como esto directamente codigo no probado
Código VB:
string ' Sub FuncionEnviarArticulo() ' vbCRLF ' Dim RespEstado , respuesta , success ' vbCRLF ' Dim wsend , metodo arti-alta modo ' vbCRLF ' Dim RH1 , RH2 ' vbCRLF ' set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1") ' vbCRLF ' ' vbCRLF ' WinHttpReq.Open "POST", "metodo & arti-alta ",modo) ' vbCRLF ' ' vbCRLF ' RH1 = "Authorization" ' vbCRLF ' RH2 = "credenciales" ' vbCRLF ' WinHttpReq.setRequestHeader ( RH1 , RH2 ) ' vbCRLF ' RH1 = "Content-Type" ' vbCRLF ' RH2 = "application/json" ' vbCRLF ' WinHttpReq.setRequestHeader ( RH1 , RH2 ) ' vbCRLF ' set json = CreateObject("Chilkat_9_5_0.JsonObject") ' vbCRLF ' success = json.LoadFile("plu.txt") ' vbCRLF * archivo con formato json ya creado ' wsend = json.emit ' vbCRLF *> variable con el registro json * ' msgbox success ' vbCRLF *> 1 correcto 0 error ' WinHttpReq.Send(wsend) ' vbCRLF *> envia los bloques ' WinHttpReq.WaitForResponse() ' vbCRLF ' respuesta = WinHttpReq.ResponseText ' vbCRLF ' msgbox respuesta ' vbCRLF ' RespEstado = WinHttpReq.Status ' vbCRLF ' Estado = RespEstado ' vbCRLF *> estado transferencia de bloques ' End Sub ' vbCRLF delimited by size into scriptCode1 end string INVOKE scriptControl1 "Reset". invoke scriptControl1 "AddCode" using scriptCode. invoke scriptControl1 "ExecuteStatement" using "FuncionEnviarArticulo".
|
|
|