Shopware 6 Store-API set newsletter recipient tags - api

I'm trying to add a newsletter recipient through store-api, which works. But when I try to add a tag inside the request, it fails. The documentation states that it is possible to add a tag as a string to the request, see here
My request looks like the following:
POST /store-api/newsletter/subscribe
{"option":"subscribe","email":"email#email.com","storefrontUrl":"http://myhost.test","tags":"men"}
I also tried to make the tags value an array, but this doesn't work either...
So my question is: how do I add a tag to the newsletter recipient through the store api?

As of Version 6.4.3.0 this seems not possible.
I tried the same request as you, as well as
"tags":["men"]
and
"tags":["uuidOfExistingTagGoesHere"]
all does not work.
Also the doc block for tags is wrong (it says "zip code" instead of a useful description).
In addition I tried to assign existing tags - this is what works via the admin API:
"tags": [
{
"id": "80df380188364f3c9bbaaa4d6b993dbd"
},
{
"id": "108428f0a37c4d11a66976adc5337c23"
}
]
Which still returns
"code": "FRAMEWORK__WRITE_MALFORMED_INPUT",
"title": "Bad Request",
"detail": "Expected data to be array.",
Also looking at the code there currently seems no handling of the tags. As far as I understand it, the tags would needed to be created on the fly
A possible fix would be the following code:
if (isset($data['tags']) { // inserted that lines
$data['tags'] = $data['tags']->all();
} // end inserted lines
$data = $this->completeData($data, $context);
Using that line, the last mentioned request works (you could then use the IDs of existing newsletter recipient tags).
Of course in this case the API docs have to be adapted.
TL;DR
In my opinion, this seems a flaw in the current Store API implementation.
I would suggest to create an issue on the Shopware 6 issue tracker.

Related

Acumatica - Filter Generic Inquiry via REST

Trying to use this Generic Inquiry's REST API, I am able to retrieve all records though would like to filter them.
Can retrieve all data with PUT {{baseUrl}}/RawDataForReport?$expand=Result with an empty body request.
When I added a field Period to filter it's only showing the first row.
An empty request body also shows the first row when I added Period.
I am not at all familiar Acumatica any useful resources would be greatly appreciated.
To filter the Generic Inquiry result with REST API you need to add the filtering parameter to the GI itself. For instancce, you have your period filter defined in the Generic Inquiry. You can define more filters the same way.
You can learn about designing GIs here: https://openuni.acumatica.com/courses/reporting/s130-inquiries-reports-and-dashboards/
Another option would be to use OData instead of REST API. in that case you would be able to use $filter parameter to filter data.
You can read more about it here:
https://help-2020r2.acumatica.com/Help?ScreenId=ShowWiki&pageid=36beb9aa-f04d-4f63-a93b-a00b1c315be0
https://help-2020r2.acumatica.com/Help?ScreenId=ShowWiki&pageid=5d97a93d-45e0-466e-ba5e-77e1ccf96643
I've been struggling to find a solution to the same problem.
I just figured it out with the help of this stack overflow post.
Acumatica run Generic Inquiry via REST API
Take a look at the last response (not the accepted answer).
Basically when you define your object in the Web Service Endpoint screen, you can define the filters (Use Populate -> Filters). these are the Parameters for the GI.
You define the results the same as you have it.
Then in your PUT request body pass the parameters.
Example:
{
"Param1": {
"Value": "Value1"
},
"Param2": {
"Value": "Value2"
}
I just tested this with Postman, and it works well.

BigCommerce storefront apis for order

Where is the documentation for /api/storefront/orders/*?
I was expecting to find it on this page.
https://developer.bigcommerce.com/api-docs/cart-and-checkout/working-sf-apis
Specifically, the documentation that would cover /api/storefront/orders/:order-id
and cover the valid inputs to the querystring. I know you can pass include, with one or more of the values as a comma separated string
payments
lineItems.physicalItems.socialMedia
lineItems.physicalItems.options
lineItems.digitalItems.socialMedia
lineItems.digitalItems.options
Edit
The checkout stencil context object used on theme\templates\pages\order-confirmation.html has this schema
{
"order_confirmation_content": "goes in the body",
"checkout_head": "goes in the head",
"order": {
"id": 206
},
"header_image": "for an img src attribute"
}
The documentation for the storefront orders API can be found here:
https://developer.bigcommerce.com/api-reference/orders/storefront-orders-api/order/ordersbyorderidget
However, as you mentioned, there are a few query parameters that are undocumented. Those are not officially supported, and they might be subject to change in the future. This is a case where our position is to hold off on documenting the API parameters until we've determined long-term support. Hope that helps to provide some context!

Which fields are required to create an event through Social Tables API

I have the following questions that I was not clear on from the API documentation:
Which fields are required to create an event?
What does "Invalid field: 0" mean? (this was an error message received when trying to create an event)
The sample body includes "spaces" as string -- is this the space name or ID?
Is this required? If yes, to create a space I need an event ID but to create an event do I need a space?
Hey thanks for using our API. It looks like the developer docs on our portal got kind of mangled. We'll be working on fixing that soon.
In the meantime, let me try to help.
So, the actual required fields for that endpoint are very minimal, here is a small sample post I made for a room here at Social Tables:
{
"name": "Dan's Office Party",
"category": "Other",
"spaces": [
{
"name": "st test"
}
]
}
The key thing here is that spaces is an array, with at least a name property attached.
The error message you referred to is a failing validation check on the type of one of the fields you submitted.
You do need a space to create an event, but as you can see, only the name is absolutely required. However, if you want to do any diagramming with that event, you'll probably want to attach a venue_id with one of our floorplan IDs in addition to the name property.
I have created an issue to update the mangled doc located at https://developer.socialtables.com/api-console#!/Events/post_4_0_legacyvm3_teams_team_events and will comment here when it is updated.

How to move an item from one parent to another?

I have a parent type call TaskList. A TaskList has many Tasks.
The simple case question that I have is how to move a Task from one TaskList to another.
I run a search query to find the set of Tasks that I want to move. The Tasks then are in the _embedded attribute of the JSON that comes back from that search. I want to then move those elements to a different TaskList. How would I do this?
Would I submit a POST to /tasklists/x with the _embedded Tasks as the body of that request?
Would I submit a PATCH to /tasks/y with a tasklist_id attribute already set?
What's the proper way to do this?
Thanks!
Moving a task implies that it already exists and has a URI. You POST that URI to the URI of the target task list.
The appropriate content type is text/uri.
As you suggested, you could submit a patch request according to : https://www.rfc-editor.org/rfc/rfc6902#section-4.4
Your json would look like something like this :
[
{
"op": "move",
"from": "/tasklists/id/tasks/id",
"path": "/tasklists/anotherId/tasks/id"
},
{
"op": "move",
"from": "/tasklists/id/tasks/id2",
"path": "/tasklists/anotherId/tasks/id2"
}
]
Hope it helps !
I'm using spring-data-rest on the server. What I ended up doing was sending a patch request to the item URL that looks like this:
{TaskList:"http:/host:port/tasklists/id"}
Here's a reference to a post which game me some insight.
https://stackoverflow.com/a/26426909/1174250
Thanks everyone for your comments :)

Select shop type using Shopify API

I'm a developer who uses Shopify Developer API. I searched API, trying to find method to retrieve information about shop business industry.
I didn't find anything. I've tried to get this information from Metafield API from store, but I've found just information about pos_attributes.
Could you help me to solve this issue? (In general, is it possible or not?)
Unfortunately that is not possible. The information you've shown is only for Shopify to tailor some stuff for your usage and it is no where linked to your account in the accessible fields.
Fortunately, you can always add custom meta-fields (information fields) to the Shopify store using the Metafield API and retrieve it at anytime anywhere.
Use the Metafield API to POST the following information directly on the store url - https://your_store_name.myshopify.com/admin/metafields.json
{
"metafield": {
"namespace": "meta", //any string will work
"key": "industry", //any string will work
"value": "Leather Manufacturing", // A string or a number
"value_type": "string" //accepted values are string & integer
}
}
Once stored, you can call it on the shop using Metafield object property. {{ shop.metafields.namespace.key.}} (in this case {{ shop.metafields.meta.industry }})
And if you want to call it using the API use GET with the url - https://your_store_name.myshopify.com/admin/metafields/metafield_id.json