Closed bilalswiftsolutions closed 4 years ago
Hi @bilalswiftsolutions this package deals with the initial Oauth handshakes, Of you can create an account then this library has successfully connected you, but once you've got the instance of the AccountingApi you're dealing directly with the api from Xero - https://github.com/XeroAPI/xero-php-oauth2
My guess is you're missing a required scope for dealing with the contacts, can you please show me which scopes you're using in the config file?
Can you please tell where i will find this scope ? because i thought that i dont need to mess with these things after using this library please guide me where i will find this scope, so i can show you here.
That's a god point, I really need to improve the docs :)
If you publish the package config file it will create a xero.php file in your config directory, there is a scopes key there.
The default scopes are
'openid',
'email',
'profile',
'offline_access',
'accounting.settings',
Which is why creating an account works (accounting.settings is required for the authorization to work hence why we add it by default), but there's no contact scopes so that won't work out of the box. You should just need to add the accounting.contacts
scope.
ok let me check
'scopes' => [ 'openid', 'email', 'profile', 'offline_access', 'accounting.settings', 'accounting.contacts', ],
I added the scope there and also restart server.. but still getting this error
sorry now i am getting this error
XeroAPI \ XeroPHP \ ApiException (400)
[400] Client error: `PUT https://api.xero.com/api.xro/2.0/Contacts?summarizeErrors=false` resulted in a `400 Bad Request` response: { "ErrorNumber": 14, "Type": "PostDataInvalidException", "Message": "JSON for post data was invalid,Error conve (truncated...)
I just updated the docs to make the scope stuff clearer, thanks for bringing that to my attention.
You'll probably need to clear your cache php artisan cache:clear
so the app fetches a new token using your new scopes, presently it will be using the old token with the default scopes.
done.this time error was in my code . it worked that @hailwood Yo saved me i spent whole previouse day on it thank you so much ..
Glad it's all working for you now. I'm going to close this issue now :)
sorry now i am getting this error
XeroAPI \ XeroPHP \ ApiException (400) [400] Client error: `PUT https://api.xero.com/api.xro/2.0/Contacts?summarizeErrors=false` resulted in a `400 Bad Request` response: { "ErrorNumber": 14, "Type": "PostDataInvalidException", "Message": "JSON for post data was invalid,Error conve (truncated...)
hi,
I am stuck at the same point. can u please help me how did you safe this?
I am getting exactly same as your error.
Thanks.
Whenever I try to create Contact it giver 401 Authorization error
XeroAPI \ XeroPHP \ ApiException (401) [401] Client error:
PUT https://api.xero.com/api.xro/2.0/Contacts?summarizeErrors=true
resulted in a401 Unauthorized
response: {"Type":null,"Title":"Unauthorized","Status":401,"Detail":"AuthorizationUnsuccessful","Instance":"ece8ffa7-a581-4638-886 (truncated...)but when I try to create Account it work perfectly
Contact Code
Account creating code