Error 500 while send POST-request to ebay large-merchant-service (Bulk Data Exchange API) for createUploadJob - ebay-api

Using the Ebay API I am getting a 500 error while sending a POST to createUploadJob.
I want to create an UploadJob for the Bulk Data Exchange API, but every time I receive "Net::HTTPInternalServerError 500 Internal Server Error readbody=true" back. I'm using Ruby on Rails to send this xml-requests feed to ebay:
< ? xml version="1.0" encoding="utf-8"?>
< createUploadJobRequest xmlns="http://www.ebay.com/marketplace/services">
< uploadJobType> "AddFixedPriceItem" < /uploadJobType>
< UUID> "ebay-upload-123456"< /UUID>
< /createUploadJobRequest>
Here are the headers (here as a hash, but they are added to the headers later):
"X-EBAY-SOA-OPERATION-NAME" => "createUploadJob",
"X-EBAY-SOA-SERVICE-NAME" => "BulkDataExchangeService",
"X-EBAY-SOA-SECURITY-TOKEN" => AUTH_TOKEN,
I'm using this ebay endpoint:
"https://webservices.ebay.com/BulkDataExchangeService"
My NET::HTTP build:
req = Net::HTTP::Post.new( [uri.path, uri.query].join('?') )
req.body = content if verb == POST and !content.nil?
if (!headers.nil?)
headers.each do | key, value |
req[key] = value
end
else
logger.debug "HEADER Empty!"
end
http.request(req)
The scheme is https and the method is POST. getItem-Fkt of the Trading API works, but for the lms I receive the above error.
-> i find something interesting in the error-logger for the responses ...
I dont understand why, in Trading API in works, maybe i have to encode it to utf-8? ...
[05.08.2015 17:49:00]:<?xml version='1.0' encoding='UTF-8'?><errorMessage xmlns="http://www.ebay.com/marketplace/services"><error>
<errorId>11002</errorId><domain>Security</domain><severity>Error</severity>
<category>System</category><message>Authentication failed : The token does not exist, the user must complete the Auth & Auth sign in process to generate token.</message>
<subdomain>Authentication</subdomain><parameter name="Param1">The token does not exist, the user must complete the Auth & Auth sign in process to generate token.</parameter></error></errorMessage>

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.

Custom error status code with gqlgen + go gin

Recently I have been updating my GO REST APIs into graphQl API's and I came across issue where I am unable to customise my status code with gqlgen.
Response I got
Headers
Status Code: 200 OK
{
data: null,
errors: [
{message: "Unauthorized access", path: ["..."]}
]
}
Expected Header
Status Code: 401 UNAUTHORISED
Any help would be really appreciating!
Assume you have a gqlgen resolver similar to this:
func (r *queryResolver) SecretItems(ctx context.Context, userID string,
password string) ([]SecretItems, error) {
// ...
if !isAuthorized(userID, password) {
return nil, errors.New("Unauthorized access")
}
// ...
}
then the described behavior is expected. Errors should be returned as part of
the response body.
GraphQL is transport agnostic. While it is often served over HTTP, it might be
served over other client-server Protocols as well. Handling errors in the
response body requires no assumptions about the protocol. Hence, you shouldn't
rely on HTTP status codes.
Handling errors in the response body has another advantage: Assume a request
contains multiple queries. Some of them succeed, some of them fail. Then the
response can contain the result of successful queries under data and errors
related to failed queries under errors.
References:
GraphQL website
Specification: Response
Hasura: GraphQL vs REST
Possible reason why you expected a 401 status code
The gqlgen docs on
authentication contain an example
where 401 status code is returned.
Why? This happens in a http handler used as middleware on the chi http server.
The 401 status code is not returned by a GraphQL resolver.

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();
}

Send DELETE request to an API endpoint using Nestful Sinatra

I want to send a DELETE request to an external API endpoint in a controller of my Sinatra application using nestful gem. I want to delete an event by sending a DELETE request to an endpoint of TeamSnap API. I have defined the following route in controller:
delete '/events/:id' do
delete 'https://api.teamsnap.com/v3/events/76674685'
end
When the API endpoint is hit with delete action, I get the following error:
*** "Delete" argument "endpoint" needs to be a number
If I send a get request to the API endpoint, I get the correct response. The get request I am using is given below:
get '/events/:id' do
get 'https://api.teamsnap.com/v3/events/76674685'
end
Can anyone confirm how can we send the DELETE request in the controller and what I am missing?
Thanks in advance!
[Solved]: I sent a DELETE request through Nestful using the following commands:
delete '/events/:id' do
request = Nestful::Request.new(endpoint, options)
request.method = 'delete'
response = request.execute
end
In the above piece of code, endpoint is "https://api.teamsnap.com/v3/events/EVENT_ID" and options is a hash which contains "Content-Type" and "Authorization" headers.

Deleting Webhooks

I have a shop with permission to read|write both orders and products. I setup some Webhooks and now I want to delete them. I am getting back 401 errors.
Starting with 4 webhooks
Trying to delete webhook 1982492
Error nil, Failed. Response code = 401. Response message = Unauthorized.
Trying to delete webhook 1982494
Error nil, Failed. Response code = 401. Response message = Unauthorized.
Trying to delete webhook 1982496
Error nil, Failed. Response code = 401. Response message = Unauthorized.
Trying to delete webhook 1982498
Error nil, Failed. Response code = 401. Response message = Unauthorized.
Ended with 4 webhooks
So, how does one delete Webhooks set on products and orders?
Webhooks (and ScriptTags) that are created by an app are automatically removed when the app is uninstalled. It looks like that might be what is happening here.
If you are doing this in response to an app/uninstalled webhook, there is no reason. It's already handled!
If you remove the endpoint that the webhook connects to, it will be deleted after 19 attempts to connect to it.
From the shopify docs (http://wiki.shopify.com/WebHook#Automatic_Retries_and_Deletion)
If an error is returned or a timeout occurs when sending a webhook,
Shopify will retry the same request for 48 hours using an exponential
back-off approach. In total 19 attempts will be made to deliver the
information.
You can also just delete the app, it will remove the webhooks
Here’s a conversation with my Shopify console to show it working correctly:
$ shopify console
using iliketurtles.myshopify.com
irb(main):001:0> include ShopifyAPI
=> Object
irb(main):002:0> w = Webhook.create topic: "orders/create", address: "http://whatever.place.com", format: "json"
=> #<ShopifyAPI::Webhook:0x007f8ff1895778 #attributes={"topic"=>"orders/create", "address"=>"http://whatever.place.com", "format"=>"json", "id"=>2026848, "created_at"=>"2012-08-10T15:11:25-04:00", "updated_at"=>"2012-08-10T15:11:25-04:00"}, #prefix_options={}, #persisted=true, #remote_errors=nil, #validation_context=nil, #errors=#<ActiveResource::Errors:0x007f8ff18948c8 #base=#<ShopifyAPI::Webhook:0x007f8ff1895778 ...>, #messages={}>>
irb(main):003:0> w.destroy
=> #<Net::HTTPOK 200 OK readbody=true>
As others have mentioned, I think your issue is permissions related.