Anyone successfully used the latest Folio Notes API to post notes for sell?
The API document said you may POST to url
https://api.lendingclub.com/api/investor/v1/secondarymarket/accounts/ACCOUNTID/orderswith JSON content like
[{"noteId":"NOTEID","price":25.00, "orderType":"SELL","expirationDate":"2018-03-14"}].
I tried but only get 400 bad request which means my JSON content is rejected. Now I am wondering whether that API document simply contains error.
Yes. I have a similar problem with that API (I use the buy function)
I have been going back and forth with LC Support for about a month now .
With the new api i tried Content-Type - application/json and Accept - application/json which failed. When I mentioned it to support they asked me to change it to text/csv. That failed too. Then they asked to change it back to application/json.. wow. now we are having funnnnnn.. and I have been sending them screenshots everytime.
They used to have a different API to buy/sell earlier which needed the "order id" and that was working fine. Now they go and change it and dont want to admit there is a problem.
It is almost impossible to "engage" LC's real software people these days. You get answers from intermediaries who don't really know, and don't really concentrate on the question, so you get a lot of muddled and quite frankly wrong answers.
I use the new buy function, but I've never switched to the new sell function, so I don't know the answer.
I used the old api which has access point like /account/buy to buy Folio notes and it still works fine. Guess we need to wait for LC to sort the new API out.
I haven't tried it yet but I wouldn't be surprised if there were bugs. There's issues in the Orders Listing too.
The new sell API works for me. I got a response 400 at first, because my expiration date was too long or too short. If you get a 400, look at the response content anyway, and you'll see the error message.
I don't know what the allowable expiration range is. Something like 1-5 days from now.
I can post code if it helps.
Yes. if you post the code that would be great.
I am still using the old API, but it would be a good backup to have, especially if LC forces us to use the new API.
Thanks Mark.
import json, requests
def sell(note_id, price, exp_str):
url = "https://api.lendingclub.com/api/investor/v1/secondarymarket/accounts/%d/orders" % accountnum
header = {'Authorization': investorid,
'Content-Type': 'application/json'}
payload = json.dumps(
[
{
'noteId':str(note_id),
'price': price,
'orderType': 'SELL',
'expirationDate': exp_str
}
]
)
resp = requests.post(url, headers=header, data=payload)
code = resp.status_code
status = resp.json()[0]['status']
print code, status
Various ways to screw it up:
>>> sell(123456789, 10.00, '2018-07-12')
400 NOTES_ARE_NOT_YOURS
>>>
>>> sell(123, 10.00, '2018-07-12')
400 NOTE_DOES_NOT_EXIST
>>>
>>> sell(148619010, 100.00, '2018-07-12')
400 ASKING_PRICE_IS_TOO_HIGH
>>>
>>> sell(148619010, 23.00, '2018-07-09')
400 ORDER_EXPIRE_DATE_TOO_SHORT
>>>
>>> sell(148619010, 23.00, '2018-07-30')
400 ORDER_EXPIRE_DATE_TOO_LONG
>>>
>>> sell(148619010, 23.00, '2018-07-12')
200 SUCCESS_LISTING_FOR_SALE
>>>
Thanks Mark.
Hi Ran,
The old API worked for me (after some trial and error). Here is sample code in C#:
const string investorId = "12345678";
const string authKey = @"xxxxxxxxxxxxxxxxxxxxxxxxxxx";
string baseAddress = string.Format("
https://api.lendingclub.com/api/investor/v1/accounts/{0}/", investorId);
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(baseAddress);
var result = client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", authKey);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "trades/sell");
request.Content = new StringContent(sellRequestBodyJson, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.SendAsync(request);
if (response.IsSuccessStatusCode)
{
string jsonResult = await response.Content.ReadAsStringAsync();
}
Hope this helps!