eBay Browse API: shopping cart add item doesn't work - ebay-api

Working with Ebay's Browse API I'm having an issue with the /shopping_cart/add_item method, when I call it, it systematically returns an error 204.
I'm working on the API's sandbox. The calls are made from an iOS application in Canada. Until then, I had no issues requesting and retrieving data from responses.
Here's how I proceed:
Using the sandbox, I retrieve mock items with /item_summary/search.
The user goes through the OAuth process and grants his shopping cart access to my app. It returns a user access token that I use for the following request.
Finally, I call add_item with the following parameters:
Request JSON parameters:
{"quantity": 1, "itemId": "v1|110385018358|0"}
Request headers:
Authorization: Bearer [sandbox user access token from step 2.]
Content-Type: application/json
X-EBAY-C-MARKETPLACE-ID: EBAY_US
Then I get an empty response (aka error 204), while it shouldn't as mentioned in the documentation.
The response I get only contains headers which are the following:
{
Status Code: 204, Headers {
Connection = ( "keep-alive" );
"Content-Encoding" = ( gzip );
"Content-Length" = ( 0 );
"Content-Type" = ( "application/json" );
Date = ( "Thu, 22 Nov 2018 15:14:32 GMT" );
RlogId = ( "t6q%60ktkjvdbwrfsl%2Bbmsgcufboja%7Ct6n%3C%3Dsm%7Eufhuoluefqqgwj%284%3F34%3F11%2Busqdrrp%2Bufmadh%7B%2Bceb%7Ce4-fij-1673bfca0ca-0x133" );
"Set-Cookie" = ( "dp1=bu1p/QEBfX0BAX19AQA**5dd7fb58^;Domain=.ebay.com;Expires=Sat, 21-Nov-2020 15:14:32 GMT;Path=/" );
"X-EBAY-C-REQUEST-ID" = ( "ri=LVOZVdAO%2FSpS,rci=n76DxeaOd61P0WBf" );
"X-EBAY-C-VERSION" = ( "1.0.0" );
"X-EBAY-REQUEST-ID" = ( "1673bfca0a9.a0962ac.25e7e.fffdc702!/buy/browse/v1/shopping_cart!10.9.98.172!esbnewesbngcos[]!add_item!10.9.103.137!r1remshopcartapi-envadvcdhidzs5k[ItemClient[!Ginger.ViewItemServiceV1.litedetails!10.9.99.212!r1viappsvc-envadvcdhidzs5k[]]!ShopcartServiceClient[!Ginger.shopcase.v2.POST!10.9.101.40!r1scartsvc-envadvcdhidzs5k[]]]" );
"X-EBAY-SVC-EP-COOKIELET" = ( "321=0001542899671242" );
"X-EBAY-SVC-TRACKING-DATA" = ( "<a>nqt=AA**&!_epec=7,6,8&nqc=AA**</a>" );
}
}
Moreover, logged in the ebay sandbox website with the test user I used above, if I open the cart, I get an error page stating:
We were unable to load your cart. Please try again. If the problem persists, contact Customer Support or send us feedback.
Still from the sandbox website, when I open any item, I get another error stating:
Unfortunately, access to this particular item has been blocked due to legal restrictions in some countries. [...]
I still hope the problem is on me and not on Ebay as their API is still a Beta.

Well ... It was nowhere in the API documentation, but hidden somewhere on the Sandbox website page "unsupported feature list for the sandbox":
Cart is not supported. You may see some functionality working, like adding items to your cart, but please do not depend on or expect cart to function properly.
Although it states that AddItem may work, it actually does not, so I guess it is expected and that I should take this as the answer to my question.
Quite frustrating...
I guess I all I can do is to wait for Ebay's partnership approval.

Related

TD Ameritrade API unable get the Access/Refresh token to work

I have been trying unsuccessfully for a couple of days to call the TD Ameritrade api to get an access/refresh token. I am getting the error "The API key in request is either null or blank or invalid."
I created the App on their site and it says status approved. I
I am 100% my redirect_uri is correct and encoded (I have been trying to get this to work for 2 nights now) In my app, it is "http://127.0.0.1" I am also sure I am not misspelling my Consumer Key. I have verified these against my app numerous times.
This is the URL I tried in Postman:
https://auth.tdameritrade.com/auth?response_type=authorization_code&redirect_uri=http%3A%2F%2F127.0.0.1&client_id={{My CONSUMER KEY}}%040AMER.OAUTHAP
I have also tried it in Python:
import requests
MYCLIENT_ID='...'
headers = {"Content-Type":"application/json"}
r = requests.post(
'https://api.tdameritrade.com/v1/oauth2/token',
data={
'response_type': 'code',
'client_id': MYCLIENT_ID,
'redirect_uri' : 'http://127.0.0.1',
}, headers = headers
)
r.json()
{'error': 'The API key in request is either null or blank or invalid.'}
Tried calling the TD Ameritrade API to get an access token.

Any POST or GET requests from the Revue API return 401

I am trying to add subscribers to my newsletter using the Revue api. According to the documentation, I need to add a header called 'Authorization' and value 'Token MY-TOKEN' in my requests.
In order to test out the API I am using Postman as seen in the screenshot below:
Any request I do to any url, ends up with a 401.
What am I missing here? The token value is copy pasted from the bottom of https://www.getrevue.co/app/integrations ('Your API key is xyz') as the documentation mentions. Double checked that there are no extra spaces added.
You cannot use the API (or at least certain entry points) without first verifying your account
If you fail to do this, your requests end with a 401 status.
Verify your account
There is no explicit option to verify your account. Instead, you need to import an existing mailing list. If you don't have a list to import, you can enforce this step by creating an artificial list, containing just your email. To do so, visit your Revue dashboard, Subscribers section, and click "Import from file":
.
Then, enter your email and two commas to skip your first and last name:
Submit and fill the next form.
When completed, a top ribbon indicates that the review is on its way:
You need to wait for the review to be completed.
Perform a request
To get your API key, visit your Revue dashboard, Account settings, Integrations, and scroll down to the bottom of the page:
Run something like:
const revueApiKey = "[your API key]";
const result = await fetch('https://www.getrevue.co/api/v2/subscribers', {
method: 'POST',
headers: {
Authorization: `Token ${revueApiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ email: "john#example.com", double_opt_in: false })
});
If you have the following when you log in to Revue
"We are reviewing your account."
You will not be able to make API calls and will get a 401.
I've talked to support on the issue and unfortunately, it's undocumented at the moment.
Took nearly a week for me to get reviewed but it's working fine now. It is at the end of the Christmas period so I am hoping they are only temporarily that slow at reviewing accounts.

JWT Bearer token in ABCchrome header

I am using ABCPdf 11 to convert html to pdf, my html page which needs to be converted required JWT token so that needs to be passed to ABCChrome so it can use the JWT token.
I have tried the following but the auth still fails:
doc.HtmlOptions.HttpAdditionalHeaders = $"Authorization: Bearer {accessToken}";
I followed example from here: https://www.websupergoo.com/helppdfnet/default.htm?page=source%2F5-abcpdf%2Fxhtmloptions%2F2-properties%2Fhttpadditionalheaders.htm
From the description in the above URL, I have also tried the below options:
doc.HtmlOptions.NoCookie = true;
doc.HtmlOptions.Media = MediaType.Screen;
After adding HttpAdditionalHeaders and when I get the http status from the pdf library I do get 401 http status code which confirms the
var imageId = doc.AddImageUrl(model.Url);
var status = doc.HtmlOptions.ForChrome.GetHttpStatusCode(imageId);
The status here is 401 - unauthorized
The HttpAdditionalHeaders property is not currently supported by the ABCChrome Engine. The only HtmlOptions supported by ABCChrome are specified here.
There are a few things you could try:
Check whether the target server supports sending the web token via GET request parameters - I guess you've probably done this already :-)
Make the AddImageUrl request URL to an intermediary web server (even a local HttpServer) to a script which can fetch the page for you based on any GET parameters.
If the service you are attempting to access accepts ajax requests you could try using javascript to inject the response into a page using XMLHttpRequest.setRequestHeader(). NB if you use a local file (e.g. file://) for this you may come across some Chromium enforced JavaScript security issues.
I do know that WebSupergoo offer free support for all their licenses, including trial licenses.
Good luck.
Emailed ABCPdf support and unfortunately ABCChrome does not support HttpAdditionalHeaders property so the work around is to download the html ourselves and convert that to PDF, see example below:
var imageId = doc.AddImageHtml(html); // <- html downloaded from auth url
Also don't forget to add paging:
// add all pages to pdf
while (doc.Chainable(imageId))
{
doc.Page = doc.AddPage();
imageId = doc.AddImageToChain(imageId);
}
for (int i = 1; i <= doc.PageCount; i++)
{
doc.PageNumber = i;
doc.Flatten();
}

intermittent error from rally 'Not authorized to perform action: Invalid key' for POST request in chrome extension

I developed a chrome extension using Rally's WSAPI v2.0, and it basically does the following things:
get user and project, and store them
get current iteration everytime
send a post request to create a workitem
For the THIRD step, I sometimes get error ["Not authorized to perform action: Invalid key"] since end of last month.
[updated]Error can be reproduced everytime if I log in Rally website via SSO before using the extension to send requests via apikey.
What's the best practice to send subsequent requests via apikey in my extension since I can't control end users' habits?
I did see some similar posts but none of them is helpful... and in case it helps:
I'm adding ZSESSIONID:apikey in my request header, instead of user /
password to authenticate, so I believe no security token is needed
(https://comm.support.ca.com/kb/api-key-and-oauth-client-faq/kb000011568)
url starts with https://rally1.rallydev.com/slm/webservice/v2.0/
issue is fixed after clearing cookies for
https://rally1.rallydev.com/, but somehow it appears again some time
later
I checked the cookie when the issue was reproduced, and found one with name of ZSESSIONID and its value became something else rather than the apikey. Not sure if that matters though...
code for request:
function initXHR(method, url, apikey, cbFunc) {
let httpRequest = new XMLHttpRequest();
...
httpRequest.open(method, url);
httpRequest.setRequestHeader('Content-Type', ' application\/json');
httpRequest.setRequestHeader('Accept', ' application\/json');
httpRequest.setRequestHeader('ZSESSIONID', apikey);
httpRequest.onreadystatechange = function() {
...
};
return httpRequest;
}
...
usReq = initXHR ('POST', baseURL+'hierarchicalrequirement/create', apikey, function(){...});
Anyone has any idea / suggestion? Thanks a million!
I've seen this error when the API key had both read-only and full-access grants configured. I would start by making sure your key only has the full-access grant.

Express Checkout Return URL C#

I am using the PayPal API in C# and calling the .SetExpressCheckout() with a return url of:
http://www.MyWebsite.com/Success?transactionId={DynamicToken}
Is it possible that PayPal isn't returning the transactionId token that I have specified or is that improbable? I am trying to diagnose a few random errors (from hundreds of successful transactions) and wondering would it ever drop the parameter I have specified in the Return URL?
Also is it safe to assume that if PayPal returns 'Successful' but I DONT call .DoExpressCheckout() that no money has been taken and I can start again?
SetExpressCheckout will always return a response something like this:
NVP Response:
TOKEN=EC-8FL80454MK5202351
TIMESTAMP=2015-09-10T02:53:36Z
CORRELATIONID=bff60e96e81c4
ACK=Success
VERSION=109.0
BUILD=000000
and you will need to redirect to the checkout page
https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-8FL80454MK5202351
Once the buyer login and completes, it will redirect to your returnurl+EC-token+payerid
http://index.php?action=ECreturn&token=EC-8FL80454MK5202351&PayerID=7SGRP23PR8MWY
So, PayPal always does return the EC-Token and after this you will need to call Doexpresscheckout API to complete the payment without this the transaction is not complete.
VERSION = 109.0
METHOD = DoExpressCheckoutPayment
TOKEN = EC-8FL80454MK5202351
PAYMENTACTION = Sale
PAYERID = 7SGRP23PR8MWY
AMT = 0.01
for example if you have a return url like this
RETURNURL = index.php?action=ECreturn?test=1
then it after Setexpresscheckout is complete, Paypal will redirect to the following URL
index.php?action=ECreturn?test=1&token=EC-5K62958L49079615&PayerID=7SGRP23PR8MWY