How to get eBay's BulkMigrateListing() API call to work - ebay-api

I'm trying to migrate an eBay listing over to eBay MIP NG by using the call BulkMigrateListing using PostMan.
From PostMan the C# call is:
var client = new RestClient("https://api.ebay.com/sell/inventory/v1/bulk_migrate_listing");
var request = new RestRequest(Method.POST);
request.AddHeader("Postman-Token", "c6a6a651-6412-4fc6-94fb-4459883e69e5");
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Authorization", "Bearer The-User-OAuth-Token");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "JSON-String", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
where JSON-String is:
{
"requests" :
[
{ "listingId" : "123456...." }
]
}
and The-User-OAuth-Token is the token from the eBay developer account suitably authorised.
But the response I get in PostMan is:
{
"errors": [
{
"errorId": 25001,
"domain": "API_INVENTORY",
"subdomain": "Selling",
"category": "SYSTEM",
"message": "A system error has occurred."
}
]
}
Has anyone successfully made a call to BulkMigrateListing? What am I doing wrong?

Here's what I've found so far:
BulkMigrateListing() is very flakey. From experience, the response.Content might be
1. {"errors":[{"errorId":25001,"domain":"API_INVENTORY","subdomain":"Selling","category":"SYSTEM","message":"A system error has occurred."}]}
2. {"errors":[{"errorId": 1001,"domain": "OAuth","category": "REQUEST","message": "Invalid access token","longMessage": "Invalid access token. Check the value of the Authorization HTTP request header."}]}
3. Missing token message
4. {"responses": [{"statusCode": 200,"listingId": "123412958208","marketplaceId": "EBAY_DE","inventoryItems": [{"sku": "ABC-004","offerId": "12347167010"}]}]}
If the call works then #4 or #1 is returned.
One way to check is to call https://api.ebay.com/sell/inventory/v1/inventory_item/THE-USER-SKU.
Returning data might be:
1. {"sku": "ABC-003","product": {"title":"The Royal Wedding Harry & Meghan Commemorative Flag With Grommets 52\" x 31\"","aspects": {"Brand": ["PMS"],"Type": [.......
2. {"errors": [{"errorId": 25710,"domain": "API_INVENTORY","subdomain": "Selling","category": "REQUEST","message": "We didn't find the entity you are requesting. Please verify the request"}
If the product has been migrated over to MIP NG then #1 is returned otherwise it's #2.

Related

insert multiple rows in a data extension by using rest api

I'm trying to insert multiple rows in my data extension by using a POST request on postman. I'm using this documentation :https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/postDataExtensionRowsetByKey.html.
Details of my first POST request :
My URL :
https://MY_SUBDOMAIN.auth.marketingcloudapis.com/v2/token
My body (by using the informations of the package created on marketing cloud) :
{
"client_id": "ssd6ssd6ssd6ssd6ssd6ss",
"client_secret": "p3sp3sp3sp3sp3sp3sp3sp3",
"account_id": "7842222",
"grant_type": "client_credentials"
}
I send the request => Status 200 OK
I copy the tokken access.
I create a second POST request.
Tab Authorization, Type = Bearer Token, I paste my token access
Details of my second POST request :
My URL :
https://MY_SUBDOMAIN.rest.marketingcloudapis.com/hub/v1/dataevents/key:EXTERNAL_KEY_OF_MY_DATA_EXTENSION/rowset
My body :
`
Host: https://MY_SUBDOMAIN.rest.marketingcloudapis.com
POST /hub/v1/dataevents/EXTERNAL_KEY_OF_MY_DATA_EXTENSION/rowset
Content-Type: application/json
[
{
"keys":{
"ID_Crawl": "test123"
},
"values":{
"Source": "2013-05-23T14:32:00Z",
"Type_contenu": "no",
"Statut_Notification": "non lu",
"Champ": "20081105",
"Origine_contenus": "test blablablablablablabla",
"Date_crawl": 02/02/2023
}
},
{
"keys":{
"ID_Crawl": "test"
},
"values":{
"Source": "2013-05-23T14:32:00Z",
"Type_contenu": "ok",
"Statut_Notification": "valide",
"Champ": "00000007",
"Origine_contenus": "test blablablablablablabla",
"Date_crawl": "02/02/2023"
}
}
]
I send the request and I had an error message (Status:400 Bad request means that bad synthax):
{"documentation":"https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/error-handling.htm","errorcode":0,"message":"Bad Request"}
Does someone know where is my mistake ?
Sorry if it seems that my mistake is a stupid one, I'm completely a beginner in api call

Saving a Postman collection variable from he response body

Trying to figure out why I cannot get this to work? Also, console does not give much of a result.
Scenario:
Making the POST request to get the response with TOKEN
Save the response token to collection variable (as the collection file will be used for importing to another testing solution in the cloud)
Using that collection variable to log out from the session
So, I need to be able to store this as a collection variable and use that token when logging out from the session/DELETE the API admin session.
Error in the console:
There was an error in evaluating the test script: JSONError: Unexpected token 'o' at 1:2 [object Object] ^
Tests:
var response = pm.response.json()
var jsonData = JSON.parse(response)
pm.collectionVariables.set("token", jsonData.response.token);
Response body:
{
"response": {
"token": "***"
},
"messages": [
{
"code": "0",
"text": "OK"
}
]
}
Thank you very much for any advice!
JSON.parse(responseBody) always gets a json representation of the response.
A complete fail safe approach would be:
pm.test("response is ok", ()=>{
pm.response.to.have.status(200)
})
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("token", jsonData.token);
Here's the approach i used.
Send the request
Check if there response is 200
If it's true set the token
pm.test("response is ok", ()=>{
if( pm.response.to.have.status(200)){
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("token", jsonData.token);
}
})
You need to change your status code depending on the condition.
Hope it helps

Amazon Advertising API throws HTTP 401 Unauthorized

I am trying to generate ads reports
The create report API gives response as
{
"reportId": "amzn1.sdAPI.v1.p44571.6153E22B.2825ae5c-126d-422c-bf10-53d2d601189a",
"recordType": "campaigns",
"status": "IN_PROGRESS",
"statusDetails": "Report is being generated."
}
but the get report status API gives UNAUTHORIZED error
{
"code": "UNAUTHORIZED",
"details": "HTTP 401 Unauthorized",
"requestId": "6C1XJ33DSF546P3XZSD"
}
My first suggestion would be to ensure you’re using a valid access token.
You should also verify correct scope value and clientID in your header.

unable to get response from an api

I a requesting an API to get response but it gives below some "JWT_TOKEN_MiSSING" response:
{
"response": {
"ids": "",
"time": 1505890122982,
"error": "JWT_TOKEN_MISSING",
"status": "failure"
}
}
API is: "https://www.viu.com/api/container/load?appid=viu_desktop&iid=9fa3fec0-9457-11e7-bee5-ed8c9b3d7f48&regionid=all&ver=1.0&aver=5.0&fmt=json&contentCountry=in&contentFlavour=telugu&languageid=en&platform=desktop&vuserid=viu-guest-9fa3fec0-9457-11e7-bee5-ed8c9b3d7f48&userid=guest-9fa3fec0-9457-11e7-bee5-ed8c9b3d7f48&ccode=IN&geo=2&id=playlist-24926470&start=0&limit=20&geofiltered=false"
I tried passing all the headers but no luck.
It seems that this API use JWT TOKEN or other tokens (such as HTTP BASIC AUTHENTICATION) to authenticate, you need to know this and add it to your request headers.

call Google auth API using Apache HttpClient

I would like to know if it is possible to call a Google API that requires auth such as the Google Calendar API using the Apache HttpClient, and no Google code or libraries. (and need the code to do it)
This is the code I have so far, its gets an auth error,
What do you use for the user/password?
HttpPost request = new HttpPost("https://www.googleapis.com/calendar/v3/users/me/calendarList/primary?key=mykey");
DefaultHttpClient client = new DefaultHttpClient();
client.getCredentialsProvider().setCredentials(
new AuthScope(AuthScope.ANY),
new UsernamePasswordCredentials(user, password));
HttpResponse response = client.execute(request);
Error:
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
You don't use Login and password you need to be authenticated once you are you will have an access token then you can call something like this.
https://www.googleapis.com/calendar/v3/users/me/calendarList/primary?access_token={tokenFromAuth}
You can authenticate to Google with any language that is capable of a HTTP POST and a HTTP GET. Here is my walk though of the Auth flow to Google http://www.daimto.com/google-3-legged-oauth2-flow/ you will need to create a Oauth2 credentials on Google Developer console to start. Then its just a matter of asking the user for permission to access their data and requesting the access.