Closed csuredag closed 7 years ago
Hi, could you please give us more info about the request(s) you made ?
I'm using your hapi client and getting a demo from slimpay page, When I catch the error I get that:
require_once 'vendors/hapiClient/autoload.php';
use \HapiClient\Http;
use \HapiClient\Hal;
// The HAPI Client
$hapiClient = new Http\HapiClient(
'https://api-sandbox.slimpay.net',
'/',
'https://api.slimpay.net/alps/v1',
new Http\Auth\Oauth2BasicAuthentication(
'/oauth/token',
'democreditor01',
'demosecret01'
)
);
// The Relations Namespace
$relNs = 'https://api.slimpay.net/alps#';
// Follow create-orders
$rel = new Hal\CustomRel($relNs . 'get-orders');
$follow = new Http\Follow($rel, 'POST', null, new Http\JsonBody(
[
'started' => true,
'creditor' => [
'reference' => 'democreditor'
]
]
));
//print var_dump(get_headers("https://api.slimpay.net/alps/v1#get-orders"));
//echo var_dump($follow);
//die();
try{
$res = $hapiClient->sendFollow($follow);
// The Resource's state
$state = $res->getState();
echo $state;
}
catch(Exception $e){
print $e->getMessage();
}
Are you using the examples given in https://dev.slimpay.com/hapi/browser ? They should work.
Yes I'm just using the examples that you have. I have created a slim.php page with the example, when I call it, it throws: 406 Not Acceptable.
I have put the code above as is, and in sendFollow function throws that error. I have tried to change in HapiClient: $headers['Accept'] = '/', but still don't work for me. I don't know what am I doing wrong.
Thanks!
Carlos
$follow = new Http\Follow($rel, 'POST', null, new Http\JsonBody(
[
'started' => true,
'creditor' => [
'reference' => 'democreditor'
]
]
));
Aren't you making a POST
request on an endpoint which accept only GET
requests ?
I have coppied this as is:
https://dev.slimpay.com/hapi/browser#get-orders
I have changed to GET, and still throwing the same error...
Sorry, that was because I have changed just to try, but with PUT and GET the same error... I don't know if I have to do anything else...
That's strange because I also took the code given and it worked for me. Are you on the lastest version ? If yes, could you dump the whole request ? (With headers and data)
Thanks a lot! I think I'm missing something...
It doesn't let me to upload the zip in this message, how can I do it?
Do what ? Are you using composer to manage your versions ?
No, I'm not using composer, I have downloaded the full version today and I have tried to connect directly.
So you do have the lastest version ? What about the request sent ?
I send you a picture of the version I have downloaded. Also the error I get.
Also the source code: https://dl.dropboxusercontent.com/u/31659387/Clientes.zip
Hi Carlos,
Did you get the latest version? https://github.com/SlimPay/hapiclient-php/releases/download/v1.0.2/hapiclient-php-v1.0.2-with-dependencies.zip
Before this version, using the wrong credentials would result in a 406 Not Acceptable error.
This also means that you have to check your app ID and secret as they may not be correct.
Please tell me if this helped fix your issue. Thanks.
Hi!!! Now it's working!
I had changed:
$follow = new Http\Follow($rel, 'GET', null, new Http\JsonBody( [ 'started' => true, 'creditor' => [ 'reference' => 'democreditor' ] ] ));
For this one:
$follow = new Http\Follow($rel, 'GET', [ 'creditorReference' => 'democreditor', 'reference' => null ]);
And works, I don't know where I got the first one.... sorry about that ;-)
Hi,
I'm getting user your examples when calling to sendFollow a 406 Not Acceptable error. I have tried to change headers but still the same.
Thanks,
Carlos