Andrew
Andrew

Reputation: 35

how to create new contacts using xero api?

how to create new contacts in Xero using API?

i have tried this API - https://api.xero.com/api.xro/2.0/Contacts but i always get this error : "oauth_problem=consumer_key_unknown&oauth_problem_advice=Consumer key was not recognised."

I don't know how to pass client id and client secret or access token in API?

passing parameter in the header is not working -

curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Basic " . base64_encode('75F16AECC7F749E08D1822B32CD110EB:lJ_h1cG7dvE5xIAXDWyFDcmGQPqtZOlHzfAzw0ImdLPKOxL5'), 'Content-Type: application/json' ]);

please help

Upvotes: 0

Views: 979

Answers (1)

rustyskates
rustyskates

Reputation: 866

Xero uses the OAuth2 authorization flow. Broadly speaking, you'll need to:

  • Send the Xero user to an authorising URL with your client id, which will result in the user being redirected to your specified redirect uri with a code
  • Swap this code for an access token using your client id and secret
  • Use the access token as a bearer token in your authorization header when you're making your request to the contacts endpoint

The full details are described in the Xero Developer docs.

Upvotes: 1

Related Questions