Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8306275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:17:57+00:00 2026-06-08T18:17:57+00:00

I’m trying to send by POST method a XML through of CURL to authenticated

  • 0

I’m trying to send by POST method a XML through of CURL to authenticated webServices, but for some reason the server is rejecting the XML file, me giving me an error 500, however another WebService than by GET method, not have problem. The following code is i’m trying.

  <?php
  $request_xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> 
  <FiltroLicitaciones xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> 
  <CantidadRegistro>10</CantidadRegistro> 
  <Texto>memo</Texto> 
  <CodigoRegion xsi:nil=\"true\" /> 
  <CodigoEstado>1</CodigoEstado> 
  <TipoFecha>FechaPublicacion</TipoFecha> 
  <FechaDesde>2011-06-01T00:00:00</FechaDesde> 
  <FechaHasta>2011-08-01T00:00:00</FechaHasta> 
  </FiltroLicitaciones>";

  //Initialize handle and set options 
  $username = 'user'; 
  $password = 'pass'; 
  $ch = curl_init();

  curl_setopt($ch, CURLOPT_URL, 'https://www.mercadopublico.cl/movil/licitaciones/porFecha');  
 //curl_setopt($ch, CURLOPT_URL, "http://localhost/server.php"); 
   curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password); 
   curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); 
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
   curl_setopt($ch, CURLOPT_HEADER, 1); 
   curl_setopt($ch, CURLOPT_TIMEOUT, 4); 
   curl_setopt($ch, CURLOPT_POSTFIELDS, $request_xml);

   $result = curl_exec($ch); 

   curl_close($ch); 

   print_r($result); 

   ?>

I don’t know if will be a error for XML malformed, but server return me a random 500 error with the following header:

HTTP/1.1 500 The server encountered an error processing the request. Please see the      server logs for more details.
Cache-Control: private
Content-Length: 1047
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 30 Jul 2012 23:53:05 GMT

I did a test in the local server, for see as the data came, the following the result this is:

HTTP/1.1 200 OK 
Date: Mon, 30 Jul 2012 23:41:50 GMT 
Server: Apache/2.2.22 (Fedora) 
X-Powered-By: PHP/5.3.14 
Content-Length: 2450 
Connection: close 
Content-Type: text/html; charset=UTF-8 

Array 
( 
 [GLOBALS] => Array 
 *RECURSION* 
  [_POST] => Array 
    ( 
        [<?xml version] => "1.0" encoding="utf-8" ?> 
        <FiltroLicitaciones xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
        <CantidadRegistro>10</CantidadRegistro> 
        <Texto>memo</Texto> 
        <CodigoRegion xsi:nil="true" /> 
        <CodigoEstado>1</CodigoEstado> 
        <TipoFecha>FechaPublicacion</TipoFecha> 
        <FechaDesde>2011-06-01T00:00:00</FechaDesde> 
        <FechaHasta>2011-08-01T00:00:00</FechaHasta> 
        </FiltroLicitaciones> 
    ) 

[_GET] => Array 
    ( 
    ) 

[_COOKIE] => Array 
    ( 
    ) 

[_FILES] => Array 
    ( 
    ) 

[_ENV] => Array 
    ( 
    ) 

[_REQUEST] => Array 
    ( 
        [<?xml version] => "1.0" encoding="utf-8" ?> 
        <FiltroLicitaciones xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
        <CantidadRegistro>10</CantidadRegistro> 
        <Texto>memo</Texto> 
        <CodigoRegion xsi:nil="true" /> 
        <CodigoEstado>1</CodigoEstado> 
        <TipoFecha>FechaPublicacion</TipoFecha> 
        <FechaDesde>2011-06-01T00:00:00</FechaDesde> 
        <FechaHasta>2011-08-01T00:00:00</FechaHasta> 
        </FiltroLicitaciones> 
    ) 

[_SERVER] => Array 
    ( 
        [HTTP_HOST] => localhost 
        [HTTP_ACCEPT] => */* 
        [CONTENT_LENGTH] => 469 
        [CONTENT_TYPE] => application/x-www-form-urlencoded 
        [PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 
        [SERVER_SIGNATURE] => <address>Apache/2.2.22 (Fedora) Server at localhost Port 80</address> 

        [SERVER_SOFTWARE] => Apache/2.2.22 (Fedora) 
        [SERVER_NAME] => localhost 
        [SERVER_ADDR] => ::1 
        [SERVER_PORT] => 80 
        [REMOTE_ADDR] => ::1 
        [DOCUMENT_ROOT] => /var/www/html 
        [SERVER_ADMIN] => root@localhost 
        [SCRIPT_FILENAME] => /var/www/html/server.php 
        [REMOTE_PORT] => 37712 
        [GATEWAY_INTERFACE] => CGI/1.1 
        [SERVER_PROTOCOL] => HTTP/1.1 
        [REQUEST_METHOD] => POST 
        [QUERY_STRING] =>  
        [REQUEST_URI] => /server.php 
        [SCRIPT_NAME] => /server.php 
        [PHP_SELF] => /server.php 
        [PHP_AUTH_USER] => user 
        [PHP_AUTH_PW] => pass 
        [REQUEST_TIME] => 1343691710 
    ) 

)

I hope can you help me.

Thanks.

Best Regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:17:58+00:00Added an answer on June 8, 2026 at 6:17 pm

    Well I’m not sure if the 500 error is from the xml but, as I see in your code the xml has no url variable :

      myxml=<xml></xml>
    

    Because as you can see from the response the url paramenter has become

     [<?xml version] => "1.0" encoding="utf-8" ?> 
    

    and this is wrong.

    If the api docs didn’t specified any url parameters then you should probably set the right curl header :

     curl_setopt($ch,CURLOPT_HTTPHEADER, Array("Content-Type: application/xml"); 
    

    Like this the server knows what to expect

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.