【问题标题】:Fetch xml forbiden 403 response获取 xml 禁止的 403 响应
【发布时间】:2021-03-17 16:17:46
【问题描述】:

我正在使用 React 开发一个项目,我必须将 XML 发送到端点,但是当我这样做时,我收到了 Forbidden 403 错误。我包括凭据和无证书

 fetch('https://cors-anywhere.herokuapp.com/http://endpoint', {
    method: 'POST',
    mode: 'no-cors',
    credentials: 'include',
    headers: (
      {'Content-Type': 'application/json;text/xml; charset=utf-8',
       "SOAPAction": "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume",
       'Accept-Language': 'en-GB',
       'Accept-Encoding': 'gzip, deflate',

       'Connection': 'Keep-alive',
       'Content-Length': Content.length                
       }),
       body: Content
    }).then(function (response) {
      toast("Procesado correctamente");
    }).catch(function (error) {
      toast("Error al procesar");
    });

这是我要发送的 xml

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/"> <soap:Header/><soap:Body><tem:ImportarXML><!--Optional:--> <tem:pvstrDatos><![CDATA[<Importar><NombreConexion>Pruebas</NombreConexion><IdCia>1</IdCia><Usuario>auxvtamed2</Usuario><Clave>lufe3698</Clave><Datos> <Linea>000000100000001001</Linea><Linea>000000204050011001001CPV000021660000000SEELENSAF                                                             +18.00                                  00101          S2019106199    Und 000000000000001.0000000000000000000.00000000012332</Linea><Linea>000000304050011001001CPV000021660000000SEELENSAF                                                             +18.50                                  00101          S2019113899    Und 000000000000001.0000000000000000000.00000000012333</Linea><Linea>000000404050011001001CPV000021660000000SEELENSAF                                                             +19.00                                  00101          S2019107799    Und 000000000000001.0000000000000000000.00000000012334</Linea><Linea>000000504050011001001CPV000021660000000SEELENSAF                                                             +19.50                                  00101          S2019110199    Und 000000000000001.0000000000000000000.00000000012335</Linea><Linea>000000699990001001</Linea> </Datos></Importar>]]></tem:pvstrDatos> <tem:printTipoError>0</tem:printTipoError> </tem:ImportarXML></soap:Body></soap:Envelope>

【问题讨论】:

    标签: javascript reactjs xml axios fetch


    【解决方案1】:

    您好,我看到您正在尝试从无效域中获取结果。

    https://cors-anywhere.herokuapp.com/http://endpoint(无效)

    应该是

    https://cors-anywhere.herokuapp.com/endpoint

    【讨论】:

    • Forbidden 403 错误是来自服务器的错误。你和 Postman 核对过吗?
    • 如果删除 cors-anywhere 是错误 415(不支持的媒体类型)Url 更改不起作用
    猜你喜欢
    • 2017-12-11
    • 2016-08-17
    • 2021-04-10
    • 1970-01-01
    • 2021-07-11
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    相关资源
    最近更新 更多