api curl_init php

0

I have the following command:

header("Content-Type: application/json");
$url="https://api.comprobanteselectronicos.go.cr/recepcion-sandbox/v1/recepcion";
$ch = curl_init();  
$cOption = array(
CURLOPT_URL            => $url,
CURLOPT_HEADER         => 1,
CURLOPT_POST           => true,
CURLOPT_HTTPHEADER     => array("authorization: Bearer ".$token->{"access_token"} ,"content-type: application/json"),
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $jsonDataEncoded
);  
@curl_setopt_array( $ch, $cOption );  
$json = curl_exec($ch);
if(!$json) {
    echo curl_error($ch);
}
$header  = curl_getinfo($ch);
curl_close($ch);

which gives me the following result:

HTTP/1.1 100 Continue

HTTP/1.1 202 Accepted
Date: Thu, 09 Aug 2018 15:56:48 GMT
Content-Type: application/json
Content-Length: 0
Connection: keep-alive
Set-Cookie: __cfduid=d1d8b3541bed295757db027650aacb03b1533830207; expires=Fri, 09-Aug-19 15:56:47 GMT; path=/; domain=.comprobanteselectronicos.go.cr; HttpOnly
Accept: */*
Accept-Encoding: gzip
Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers
Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3600
Breadcrumbid: ID-pebpriin0301-prod-comprobanteselectronicos-go-cr-38169-1531264961625-0-16751655
Location: https://api.comprobanteselectronicos.go.cr/recepcion-sandbox/v1/recepcion/50609081800011033069700100001010000000001186111450
User-Agent: Go-http-client/1.1
X-Ratelimit-Limit: 1000
X-Ratelimit-Remaining: 976
X-Ratelimit-Reset: 1533832094
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 447b6a2e6818b955-MIA

It's good here (although I would like to know if having the location of the header without having to put CURLOPT_HEADER = > 1 this would be a plus answer )

Now when I do the query to the api for the document I do it in the following way

        $url="https://api.comprobanteselectronicos.go.cr/recepcion-sandbox/v1/recepcion/".$Clave;
    $ch = curl_init();  
    $cOption = array(
    CURLOPT_URL            => $url,
    CURLOPT_HEADER         => 0,
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => array("authorization: Bearer ".$token->{"access_token"} ,"content-type: application/json"),
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => $jsonDataEncoded
    );  
    @curl_setopt_array( $ch, $cOption );  
    $json = curl_exec($ch);
    if(!$json) {
    echo curl_error($ch);
    }
    curl_close($ch);

where $ key is the document number that is sent but I get it

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /api/v1/recepcion/50609081800011033069700100001010000000001186111450. Reason:
<pre>Not Found</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>
</body>
</html>

and I do not understand why if the document number is the same

    
asked by Oscar Melendez 09.08.2018 в 18:30
source

0 answers