Shopware Product API response with no content and error 204 (No Content) Error - api

So while trying to test how to create a product, with as minimal data as possible, using the Shopware 6 API i get a Status 204 (No Content) response with an empty response.
When i press "Send" again i get a Status 400 error with this message:
{
"errors": [{
"status": "400",
"code": "CONTENT__DUPLICATE_PRODUCT_NUMBER",
"title": "Bad Request",
"detail": "Product with number \u002212345667891\u0022 already exists.",
"meta": {
"parameters": {
"number": "12345667891"
}
}
}]
}
When i check the Shopware Backend and search for the product, i get no result.
When i try searching the MySQL Product-Tables i get no result aswell.
Iam using this site: https://reqbin.com/
And I call the URL: https://www.my-url.de/api/product via POST Request.
As authorization i use a bearer token i grab from the getToken GET-Request.
My Request-Content looks like the following:
{
"name": "Aarons Testartikel of Doom",
"taxId": "f68a9c3c86864c2ea7597062fc457cf7",
"price": 3,
"productNumber": "12345667891",
"stock": 5,
"active": true
}

The 204 status code you get on your first request indicates that the request was handled successful. According to the HTTP-Standard all 2xx status codes can be considered successful. Shopware by default returns a 204 - No Content with en empty response body to all write requests over the API, but you can provide a _response query parameter to your POST-Request and Shopware will return a 200 response with the same data you'll get if you make a GET-Request to read the data of the added product.
In your case the URL would be https://www.my-url.de/api/product?_response=1.
The reason for the Error on the second request is that the product number needs to be unique, so you can't add another product with the same product number. Changing the product number before you do the second request should work again.
The Error also indicates that the first Write-Request was indeed successful, to make sure that your shopware installation is connected to the Database you think it is, you can check the .env file in the root folder of your installation, there should be a DATABASE_URL variable defined.

Related

Twitter API v2 - Making a loop that collect an ID from a response, and insert on the next request

I'm having trouble looping a group of requests on the "Full Archive Search" on Twitter API v2.
I need to get all the responses from a determined subject, but there is a limit of tweets per page. To cover this, a "next_token" is generated on the body response. I need to make lots of requests using the "next_token" as a parameter to the subsequent request.
The thing is, I have no idea how can i make a loop, and collect all the responses.
There are more than 500.000 tweets in the period that I am searching for. And the limit of tweets per page is 500.
I'm using the default request from the "Full Archive Search", on Twitter API, using "query", "start_time" and "end_time"
The response that I got has a limit of tweets per page. At the bottom of each page, have the following lines:
"meta": {
"newest_id": "1321965025809059840",
"oldest_id": "1321964960956768256",
"result_count": 8,
**"next_token": "b26v89c19zqg8o3fosbski4ttnan7ven9iyr8gbrdfiwt"**}
I need to get that "next_token" and add it to the subsequent request.
Does anyone have an idea how can i collect all this data?
Edit: I tried to use the code below to get the "next_token":
pm.test("Set Next Token", function () {
var jsonData = pm.response.json();
console.log(jsonData.next_token)
pm.collectionVariables.set("next_token", jsonData.next_token);
});
But it returns to this error:
{
"errors": [
{
"parameters": {
"next_token": [
"null"
]
},
"message": "Invalid 'next_token':'null'."
}
],
"title": "Invalid Request",
"detail": "One or more parameters to your request was invalid.",
"type": "https://api.twitter.com/2/problems/invalid-request"
}

Strapi API register returning a 400 error

I’ve been creating a web app with a login and a registration function and so far everything has been going great. I managed to connect the app to the api/auth/local api endpoint and send some nice post requests.
Now, I’ve been trying to send requests to the http://localhost:1337/api/auth/local/register endpoint and without any success. I’ve been doing this according to:
https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#registration
I keep getting a 400 error:
{
"data": null,
"error": {
"status": 400,
"name": "ApplicationError",
"message": "An error occurred during account creation",
"details": {
}
}
}
If I try to send a request with an email that’s already registered in strapi, the response will give me the correct error:
{
"data": null,
"error": {
"status": 400,
"name": "ApplicationError",
"message": "Email is already taken",
"details": {
}
}
}
In the public and authenticated user roles, I’ve allowed every single one of them, for now.
Enable confirmation emails are set to false.
Email confirmation
Public user permission
For the headers, I’m using Content-type : application/json
the raw json body I'm posting:
{
"email": "manager1#strapi.io",
"password": "testtest1",
"username": "manager1"
}
This is my first project with strapi and so far it went pretty well. I’m not sure if I’m missing out on something or if I’m doing something else wrong.
Any help is appreciated!
I figured it out, it wasn’t as complicated as I expected.
In the user I had different fields, like firstName, lastName etc. All of these fields were required.
I made the fields not required, and now it works.

Accept type is invalid , INVALID_ACCEPT_TYPE.GMP_ITEM_QUERY_API ( Walmart ItemSearch API Error )

Searching Item from Walmart Catalog Error 406 Not Acceptable
"code": "INVALID_ACCEPT_TYPE.GMP_ITEM_QUERY_API"
"info": "Accept type is invalid."
The Walmart Item Search API allows us to query the Walmart.com global product catalog by item keyword, UPC or GTIN.
API CALL
GET https://marketplace.walmartapis.com/v3/items/walmart/search?query=ipad
WM_SVC.NAME: 4PSite
WM_QOS.CORRELATION_ID: {{$guid}}
Authorization: Basic NDdmNzA4MY0LdfgfgdfghMThlNDQwOkRQZFRRYTdpZ3GDFGDFRFDGDFGETmRsVEZPOHZPRCYUw0RHRXM296VGlsVXFaZFZmTHpTdVNsdfdsafadfgesgdfg0....
WM_SEC.ACCESS_TOKEN: eyJraWQiOiI3NGU2ODE4Mi1iMzJkLTQ4ZDEtYThjOS03YjMyNDljMTk1NmQiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..EzxhCQ9QIKhWMvdI._uvEAJGZtvfjX7AbwGd.....
API CALL ERROR
"error": [
{
"code": "INVALID_ACCEPT_TYPE.GMP_ITEM_QUERY_API",
"info": "Accept type is invalid.",
"severity": "ERROR",
"category": "DATA",
"causes": [],
"identify": {
"entry": []
}
}
Need help...
Image: Error Result of Postman call
As mentioned in my comment, try adding the header "Accept" as "application/json" and it should work.
For more context, it is a GET call and "Accept" is more relevant than the Content-Type which is mostly associated with POST/PUT calls that take body as well.

Walmart API Error: WM_CONSUMER.CHANNEL.TYPE set null or invalid

My client has a Walmart marketplace store and we are trying figure out how to successfully make the Walmart API's Multiple Item Inventory for All Ship Nodes API call.
The API production URL is :
https://marketplace.walmartapis.com/v3/inventories
The purpose of this call is getting the inventory of the store using the API.
Unfortunately, we are stuck because we don't know what value to put for WM_CONSUMER.CHANNEL.TYPE.
As a result, the API response is unsuccessful and gives this error:
{
"error": [
{
"code": "INVALID_REQUEST_HEADER.GMP_GATEWAY_API",
"field": "WM_CONSUMER.CHANNEL.TYPE",
"description": "WM_CONSUMER.CHANNEL.TYPE set null or invalid",
"info": "One or more request headers are invalid.",
"severity": "ERROR",
"category": "DATA",
"causes": [],
"errorIdentifiers": {}
}
]
}
Where can the value of WM_CONSUMER.CHANNEL.TYPE be found?
I had the same exact issue. I had to open a ticket with support to get the WM_CONSUMER.CHANNEL.TYPE.
Just an FYI, this didn't solve the problem as the value they gave us still resulted in the API returning the same error code.

Can we add multiple labelId in history.list API for gmail?

I want to get the result of all INBOX mails and all SENT mails in one API call using the historyID and the history.list Gmail-API.
Refer:
https://developers.google.com/gmail/api/v1/reference/users/history/list
When I am hitting the following GET request :
https://www.googleapis.com/gmail/v1/users/{userID}/history?startHistoryId={historyID}&labelId=SENT&labelId=INBOX
I only get the SENT label messages.
Seems like the API only accepts single & first query param for labelId.
Is there a way to get multiple labelIds' response in a single API call?
I think it would not be possible, I tried making a multiple request and it this response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Invalid label value in query"
}
],
"code": 400,
"message": "Invalid label value in query"
}
}
I would suggest to call it separately for each labelID but you can try filing a feature request for this.
Hope this helps.