WooCommerce rest api include parameter not fetching variation with variable product - rest

https://example.com/wp-json/wc/v3/products/10 product type=variable and it is working fine
https://example.com/wp-json/wc/v3/products/11 product type=variation and it is working fine
But it fetch only one product (with id 10) using include parameter like
https://example.com/wp-json/wc/v3/products?include=10,11
I need help so that i can fetch 2 or more products (any type) in one API call

Do you need to retrieve all the products in woo commerce. If try with this call " /wp-json/wc/v3/products"

A bit late but maybe someone has the same problem still
The include parameter should be array and as this thread explains How to pass an array within a query string?
you should send your parameters as this
https://example.com/wp-json/wc/v3/products?include[]=10&include[]=11

Related

How to get only specific value in REST API JSON response?

I'm using REST API to get data from my Learndash courses. I need a list of ID, title, and feature images. I used .. to get the lists of IDs and titles. But when I use _embed I also get IDs from wp:featuredmedia. So I want just source_link from wp:featuredmedia
I tried _fields parameter and also _embedded. Nothing is working
My question is, How to get only the id, title, and featuredmedia link from REST API call?

Proper multi-id syntax when using the custom_file_ids[] query parameter for the CLIO API "contacts" endpoint

What is the correct API syntax for using the custom_file_ids[] query parameter to specify multiple fields (but not all) in the CLIO API contacts result set? I need to specify multiple custom fields. I can get it to work for a single field, but not multiple fields at the same time.
Specifically, how do I specify and delimit the multiple fields? I have tried the following:
custom_file_ids[]=1234567,2345678
custom_file_ids[]=[1234567,2345678]
custom_file_ids[]=(1234567,2345678)
custom_file_ids[]={1234567,2345678}
custom_file_ids[]=1234567:2345678
The API documentation at https://app.clio.com/api/v4/documentation is silent on the list syntax that it expects.
Below is one specific API call I tried (both the actual URL-encoded call, and a decoded one for clarity) using a simple comma-delimited list, but which only returns custom field data for the first ID in the list--not the second. If I enclose the ID list in any kind of brackets (per above), the endpoint returns a 404 error.
https://app.clio.com/api/v4/contacts?custom_field_ids[]=1234567%2C2345678&custom_field_values[4529224]=true&fields=id%2Cname%2Cprimary_address%2Cprimary_work_address%2Cis_client%2Ctype%2C%20primary_email_address%2Cprimary_phone_number%2Ccustom_field_values%7Bid%2Cfield_type%2Cfield_name%2Cvalue%2Ccustom_field%7D
https://app.clio.com/api/v4/contacts?custom_field_ids[]=1234567,2345678&custom_field_values[4529224]=true&fields=id,name,primary_address,primary_work_address,is_client,type,primary_email_address,primary_phone_number,custom_field_values{id,field_type,field_name,value,custom_field}
Try:
custom_file_ids[]=1234567&custom_file_ids[]=2345678
I was able to do this with Contacts Custom Fields by putting custom_field_id[] on the URL as many times as you have IDs.
I hope this helps.

Get specific product with id via Rest API Magento 2

I want to get the information from an specific product.
I am using this reference in this moment, and get all the products in given searchCriteria:
http://www.mysite.co/rest/V1/products-render-info?storeId=1&currencyCode=cop
Is there a way I can send the product id in the url and get only all its information?
You can add the filter
http://www.mysite.co/rest/V1/products?searchCriteria[filterGroups][0][filters][0][field]=entity_id&searchCriteria[filterGroups][0][filters][0][value]=1&searchCriteria[filterGroups][0][filters][0][condition_type]=eq
use field entity_id instead of id, value is product id here 1, condition_type is equal to here eq.
You can fetch product info by SKU, not ID.
API endpoint (get method) will pull product info. vendor/magento/module-catalog/etc/webapi.xml
/V1/products/:sku
So, your rest API calling URL should be like this
http://www.mysite.co/rest/V1/products/productsku
Note: If you want to fetch product info by id, you probably need to create a simple rest API. you can check this out.
https://magento.stackexchange.com/questions/282480/i-am-new-here-i-want-to-know-how-can-i-create-my-own-simple-api/282730

Retrieve count related lookup value using REST in SharePoint 2016

I am following this post:
http://pawansatope.blogspot.com/2012/01/how-to-create-count-related-lookup.html
Now I want to get the same results(i.e DepartmentTitle and NbOfEmployees) values programatically using the REST api.
I've tried different variations of:
/items$select=Title,NbOfEmployees/...&$expand=NbOfEmployees
but haven't got any luck.
Has anyone tried this?
Many thanks!
I created the lookup field "NbOfEmployees" (Department(Count Related) to Employee Data list like this:
This is the two list data:
Then for NbOfEmployees field (Department count), directly get in Rest API:
http://sp2016/_api/web/lists/getbyTitle('Department')/items?$select=NbOfEmployeesId,Title
Actually, this value is the real count value for department, no need to expand in Rest.

Is there a way to assign the primary category for a product in demandware using the Open Commerce API (OCAPI)?

The primary category of a product is present in the product document (primary_category_id) in the DATA API but cannot be written. After sending a PATCH update of the product with a different primary_category_id, it doesn't change.
Is there a way of doing this through the OCAPI?
Can be some limitation for PATCH Method.Fields that can be updated:
name,
page_description,
long_descripton,
page_title,
page_keywords,
brand,
ean,
upc,
manufacture_sku,
manufacture_name,
searchable,
unit,
searchable,
online_flag,
default_variant_id.
Try with PUT Method. PUT https://hostname:port/dw/data/v19_1/products/{id}. Also,
please check Request Document.
At this time it does not appear that this is possible to manage via OCAPI.
I suspect that in the future you'd be able to achieve it using the following resources:
DELETE /catalogs/{catalog_id}/categories/{category_id}/products/{product_id}
followed by:
PUT /catalogs/{catalog_id}/categories/{category_id}/products/{product_id}
With a ProductCategoryAssignment document in the PUT call.
However, this would require that Salesforce adds those attributes to the ProductCategoryAssignment document.
The reason I suggest this is where it would be added is that within a catalog import document (XML) the flags are associated with a similar resource representation. eg:
<category-assignment category-id="gear-bags-backpacks" product-id="NSF4003100">
<primary-flag>true</primary-flag>
</category-assignment>