Have the API a issue?
carloscruz85 opened this issue · 17 comments
Hi, I'm new with your API but seems the example you have in your site is down: http://api-example.splitwise.com/
In other side, the endpoint
https://secure.splitwise.com/api/v3.0/get_access_token show a "File not found" message.
There is a problem with the API or I am not understand something?
Have you a updated example site for the API?
We took down the example site a while ago, but you can still take a look at the source code here: https://github.com/splitwise/api-example. I'm not sure if it works any more, and I'd personally look at the new docs authorization examples for getting started.
The get_access_token endpoint is POST only, so you'll get a 404 when you try to GET it.
Thanks so much for your help, I am really new in this, registering my app in splitwise I have:
Consumer Key,
Consumer Secret,
Token URL,
and Authorize URL.
How with this data I will have the access token to make request to the api?
I would generally recommend finding an oauth library in your language of choice, then following the instructions on getting it set up. We have examples in javascript and ruby here: https://dev.beta.splitwise.com/#introduction
Hi, I just get the access token watching examples, but now when I try to create a expense get a error:
{"error":"Your device's clock is off by more than 12 hours, and the server has rejected your request. Please correct the time on your device and try again."}
What can I do to resolve?
Hi, that error message means that however you are signing your OAuth messages is not using the current, correct time. It's possible we're mis-detecting the problem and something else is happening.
Is possible I made a bad request in https://secure.splitwise.com/api/v3.0/create_expense
This are my headers:
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
oauth_consumer_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json; charset=utf-8
this the body
{payment:0,cost:7,description:none}
Have you a examples, the documentation in your oficial site are prety hard to understand
Sorry the docs are bad. We've been in the middle of updating them for a while now and haven't really got them to a good spot yet. In most cases, the inputs for the various calls match the outputs, though the system for nested parameters is a bit horrible on the input side.
Your body should look something like:
"payment": 0,
"cost": "10.00",
"description": "A description",
"currency_code": "USD",
"user__0__id": 123456,
"user__0__paid_share": "10.00",
"user__0__owed_share": "5.00",
"user__1__id": 123457,
"user__1__owed_share": "5.00"
One of the user id values should be for the user who is logged in, and the other must be a user that user is friends with. These should be submitted as form data.
I have been trying to create and expense entry in splitwise from my application using splitwise API (https://secure.splitwise.com/api/v3.0/create_expense). I am always getting the below error.
All other APIs (get_current_user, get_friends, get_grooups, etc) are working fine and I am able to retrieve data
Authentication : OAuth2.0, Bearer
Request
API: create_expense
request body:
{
payment:false,
cost: 100.00,
description:”test”,
users__0__user_id: current user id,
users__0__paid_share:100.00,
users__0__owed_share:50.00,
users__1__user_id:friend user id,
users__1__paid_share: 0.00,
users__1__owed_share:50.00
}
Response
body= {"errors":{"base":["Invalid API Request: you do not have permission to perform that action"]}}
message = Forbidden
code = 403
@mvsreejithfrnds, are you able to issue any other POST requests to other endpoints with that token?
@jas14 I have not tried posting any request to the API, Only create expense is the api I used as POST method. All other API I am using is GET
The scenarios in which you'd get a 403 on that endpoint that jump to mind are:
- Your OAuth credentials are invalid. Your client may be using cookie authentication instead of OAuth, or maybe you don't have a valid access token.
- The users you provided aren't direct friends or in any of the same groups.
@jas14 All the post request are failing with same error as I mentioned above. I am able to retrieve all the friends detail group details and current user details (All get operations).
- redirecting page to getAuthorizationUrl (https://secure.splitwise.com/oauth/authorize?response_type=code&client_id=)
- loading splitwise login page, entering the credentials
- authenticated and redirecting to confirmation page, confirming the access.
- getting the code from the url. set access token with the code
- performing other operations. all GET methods are working POSTs are failing.
I have changed to oauth1.0 now it is different. I could post the create expense request successfully but not reflected in Spiitwise
Expense create completed without error but not reflected in Splitwise
Api
create_expense
Request
users__0__owed_share : 75.0
cost : 150.0
users__1__owed_share : 75.0
users__1__user_id :
users__0__paid_share : 0.0
description : "test"
payment : false
users__1__paid_share : 150.0
users__0__user_id :
Response
Response{code=200, message='OK', body='null', headers={Transfer-Encoding=chunked, null=HTTP/1.1 200 OK, Server=nginx, X-Request-Id=2915a687-0d9b-4e6e-a9f0-18bf835d1dd5, X-Runtime=0.037593, X-Content-Type-Options=nosniff, Connection=keep-alive, Pragma=no-cache, Date=Fri, 03 Jan 2020 23:32:03 GMT, Via=1.1 vegur, Referrer-Policy=origin, X-Frame-Options=SAMEORIGIN, Strict-Transport-Security=max-age=31536000, Cache-Control=no-cache, no-store, max-age=0, must-revalidate, Content-Disposition=inline; filename="response.json", X-Xss-Protection=1; mode=block, Set-Cookie=, Vary=Accept-Encoding, Expires=Fri, 01 Jan 1990 00:00:00 GMT, Content-Type=application/json; charset=utf-8}}
@mvsreejithfrnds, glad to see you got your authentication flow working. For that last issue, please see https://dev.splitwise.com/#errors :
... Even when a call is successful and returns a 200 OK HTTP response, the body of the response may include a key called error or errors. This is usually used to communicate validation errors. For example, if you submit an expense without any cost, we may return an errors key as part of the JSON response.
Can anyone please provide the proper document for creating an expense with friend without a group. I tried many ways, but end up in creating expenses which both owes and paid were me and its not including my friend's account at all.
@jas14
Thanks in advance!
@sasinetindia see this comment: #5 (comment)