'Send Post Request WebClient C# .Net 2.0
I'm trying to send a POST request to a WebService, but I'm getting a (308 permanent redirect) error, I'm using System.Net.WebClient (All the program works in .Net 2.0 so I can't use System.Net.Http) Here is my code (makeRequets() method returns XML below this block)
using (var client = new WebClient())
{
client.Headers[HttpRequestHeader.ContentType] = "text/xml";
var data = Encoding.UTF8.GetBytes(makeRequest());
byte[] result = client.UploadData(connection, "POST", data);
string resultContent = Encoding.UTF8.GetString(result, 0, result.Length);
}
This is the content I'm trying to send.(It works in postman)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="something.com/">
<soapenv:Header/>
<soapenv:Body>
<procesarLotePorFacturaRequest xmlns="something.com/">
<procesarDocumento>
<rDE>
<DE>
<gOpeDE>
<iTipEmi>1</iTipEmi>
</gOpeDE>
<gTimb>
<iTiDE>1</iTiDE>
<dNumTim>14601619</dNumTim>
<dEst>9</dEst>
<dPunExp>9</dPunExp>
<dNumDoc>22712</dNumDoc>
</gTimb>
<gDatGralOpe>
<dFeEmiDE>2022-04-12T12:34:56-04:00</dFeEmiDE>
<gOpeCom>
<iTipTra>1</iTipTra>
<iTImp>1</iTImp>
<cMoneOpe>PYG</cMoneOpe>
</gOpeCom>
<gEmis>
<dRucEm>80005366</dRucEm>
<dDVEmi>4</dDVEmi>
</gEmis>
<gDatRec>
<iNatRec>1</iNatRec>
<iTiOpe>1</iTiOpe>
<dRucRec>5307630</dRucRec>
<dDVRec>3</dDVRec>
<iTiContRec>1</iTiContRec>
<dNomRec>BARRETO MENDEZ EDER MATIAS</dNomRec>
<dDirRec>A</dDirRec>
<dNumCasRec>0</dNumCasRec>
<cPaisRec>PRY</cPaisRec>
<dDesPaisRe>Paraguay</dDesPaisRe>
</gDatRec>
</gDatGralOpe>
<gDtipDE>
<gCamFE>
<iIndPres>1</iIndPres>
</gCamFE>
<gCamItem>
<dCodInt>614143297809</dCodInt>
<dDesProSer>R CAPELETIS - POLLO 500GR PAQ </dDesProSer>
<dCantProSer>3.00</dCantProSer>
<gValorItem>
<dPUniProSer>12500</dPUniProSer>
<dTotBruOpeItem>37500</dTotBruOpeItem>
<gValorRestaItem>
<dDescItem>0</dDescItem>
<dTotOpeItem>37500</dTotOpeItem>
</gValorRestaItem>
</gValorItem>
<gCamIVA>
<iAfecIVA>1</iAfecIVA>
<dTasaIVA>10</dTasaIVA>
</gCamIVA>
</gCamItem>
<gCamCond>
<iCondOpe>1</iCondOpe>
</gCamCond>
</gDtipDE>
<gTotSub>
<dSubExe>0</dSubExe>
<dSub5>0</dSub5>
<dSub10>37500</dSub10>
<dTotOpe>37500</dTotOpe>
<dRedon>0</dRedon>
</gTotSub>
</DE>
</rDE>
<parametrosProcesamiento>
<retornarKuDE>true</retornarKuDE>
<retornarXmlFirmado>true</retornarXmlFirmado>
<templateKuDE>1</templateKuDE>
<forzarReingreso>false</forzarReingreso>
<docAsociado>
<numero>1575</numero>
<tipo>4</tipo>
</docAsociado>
</parametrosProcesamiento>
</procesarDocumento>
</procesarLotePorFacturaRequest>
</soapenv:Body>
</soapenv:Envelope>
Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
