Skip to content
This repository has been archived by the owner on Jun 25, 2023. It is now read-only.

AUXILIO - Menssage: "Unauthenicated" #6

Open
5 tasks done
carlillus opened this issue Oct 30, 2020 · 1 comment
Open
5 tasks done

AUXILIO - Menssage: "Unauthenicated" #6

carlillus opened this issue Oct 30, 2020 · 1 comment

Comments

@carlillus
Copy link

carlillus commented Oct 30, 2020

Saludos.

¿Alguien me puede Ayudar?

Alguien a consumido el API REST desde Visual FoxPro?

### Ya hice la prueba desde el PostMan y hace la prueba perfectamente.

Tengo un ERP en Visual FoxPro:

  • Copio en PostMan y Pego en VFP la URL (exacta).
  • Copio en PostMan y Pego en VFP el TOKEN (exacto).
  • Creo la Conexión.
  • Me Conecto.
  • Hago en Envío.
  • El retorno del Envío me arroja esto:

Menssage: "Unauthenicated"

### EN TEORIA creo que mi problema esta en la Conexión desde VFP pero espero su ayuda.

Un compañero envió este código en VB6:

If RSRS.RecordCount > 0 Then
	ReenviarFacturaAPI:Set xmlhttp = New MSXML2.ServerXMLHTTP60

If TipoInvoice = "GENERAL" Then
	If RSCajaFE.Fields("TestSetIDFE") = "" Or IsNull(RSCajaFE.Fields("TestSetIDFE")) Then
		xmlhttp.Open "POST", RSRS.Fields("UrlAPI21") & "/api/ubl2.1/invoice", False
	Else
		xmlhttp.Open "POST", RSRS.Fields("UrlAPI21") & *"/api/ubl2.1/invoice/" & RSCajaFE.Fields("TestSetIDFE"), False
	End If
Else
	If TipoInvoice = "AIU" Then
		If RSCajaFE.Fields("TestSetIDFE") = "" Or IsNull(RSCajaFE.Fields("TestSetIDFE")) Then
			xmlhttp.Open "POST", RSRS.Fields("UrlAPI21") & "/api/ubl2.1/invoice-aiu", False
		Else
			xmlhttp.Open "POST", RSRS.Fields("UrlAPI21") & "/api/ubl2.1/invoice-aiu/" & RSCajaFE.Fields("TestSetIDFE"), False
		End If
	Else
		If TipoInvoice = "EXPORTACION" Then
			If RSCajaFE.Fields("TestSetIDFE") = "" Or IsNull(RSCajaFE.Fields("TestSetIDFE")) Then
				xmlhttp.Open "POST", RSRS.Fields("UrlAPI21") & "/api/ubl2.1/invoice-export", False
			Else
				xmlhttp.Open "POST", RSRS.Fields("UrlAPI21") & "/api/ubl2.1/invoice-export/" & RSCajaFE.Fields("TestSetIDFE"), False
			End If
		End If
	End If
End If

xmlhttp.setRequestHeader "accept", "application/json"
xmlhttp.setRequestHeader "Authorization", "Bearer " & Trim(RSRS.Fields("PasswordAPI"))
xmlhttp.setRequestHeader "Content-Type", "application/json"
xmlhttp.setRequestHeader "X-CSRF-TOKEN", " "
xmlhttp.send *PlantillaJSON

Yo uso este Código en VFP9:

ruta = "http://localhost/apidian2020/public/api/ubl2.1/invoice/e423daa7-201c-4bf9-a751-acebd3e3984a"	
token = "08f86bff3506b88fb95812d8942b4f138c84470bb72026abdfc4443b1038adea"
post_connect = CREATEOBJECT('MSXML2.ServerXMLHTTP')	
post_connect.Open("POST", ruta, .F.)
*******
post_connect.setRequestHeader("accept", "application/json")	
post_connect.setRequestHeader("Content-Type", "application/json")	
post_connect.setRequestHeader("Authorization", "Bearer Token="+token)
*******
post_connect.Send(json_para_envio)
json_respuesta = post_connect.responsetext

Pero en JSON_RESPUESTA me devuelve Menssage: "Unauthenicated"

@DD4F
Copy link

DD4F commented Nov 12, 2020

Saludos
Verifica el TOKEN

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants