Given node for Storefront.Product with string id, how to get productId for Admin API - shopify

I'm using GraphQL shopify buy-sdk for Android, and getting node for Product, by string id like:
"id" -> "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzEwMDcyMDgwOTc1"
this is node id
but to get, say, product metafields, i have to make request to Admin API
https://SHOP.myshopify.com/admin/products/{productId}/metafields.json
where {productId} is numeric id of Product, like:
6243834538
I cannot use node id in REST API request, getting 400 "Bad Request".
So the question is - how to get numeric product id for node in GraphQL?
Thanks!

You can simply do a base64 decode to the string id. By decoding (base64) the string you gave in the example I found something like this.
gid://shopify/Product/10072080975
You can trim the string to get the product id from the end and can use in the rest api of shopify admin api.

Related

How to apply not filter in shopify rest api?

I'm using Shopify API to get all the products. GET /admin/products.json. Found that i can apply filters only to title, vendor, handle, product type, collection ID.
In order to get all the products which has 'aaa' as vendor and 'bbb' as product type. I have applied it as, GET /admin/products.json?vendor=aaa&product_type=bbb.
No i need to get all the products which DONT have vendor 'aaa'. I have tried with != operator. It haven't worked for me. Can you please help me on this?
You can run queries like that using the new admin GraphQL API.
POST /admin/api/graphql.json HTTP/1.1
X-Shopify-Access-Token: [your-token]
Content-Type: application/graphql
query {
products(first:50, query: "NOT vendor:aaa") {
edges {
node {
id
title
vendor
}
}
}
}

Softlayer API To get a particular Storage ID for a particular Order ID

After placing order for a storage in softlayer, I need to get that storage id for a particular order id.The api call i am using, is giving me a list of storage ID. But, if user orders for a storage, only one storage id the user should get right.
So, the api is not properly filtering and not getting a particularly storage id for a particular order id . The rest api, i am using is given below and please tell me what should be the proper filtering ,
"https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Account/getIscsiNetworkStorage.json?objectFilter={"networkStorage": {"billingItem": {"nasType": { "operation": "ISCSI"}, "orderItem": {"order": {"id":{"operation":"[orderID]"}}}}}} "
This api is provided by softlayer team
Regards,
Debartha
use this request:
GET https://api.softlayer.com/rest/v3/SoftLayer_Account/getIscsiNetworkStorage?objectMask=mask[billingItem[orderItem[order]]]&objectFilter={"iscsiNetworkStorage": {"billingItem": { "orderItem": {"order": {"id":{"operation":5208963}}}}}}
note: replace 5208963, with your orderID
Basically all the devices must have a billingItem and that billingItem should have orderItem.order.id property, so you can use this filter to get any device using the orderID property, you just to need to make sure that the "iscsiNetworkStorage" value, in the filter, has the same name as the method you are calling (in this case getIscsiNetworkStorage method ), but without the pre-fix "get" and it must start with lower case e.g.
getIscsiNetworkStorage -> iscsiNetworkStorage
Regards

eBay API findItemsAdvanced call ignores categoryID

Any attempt to make an eBay API call to findItemsAdvanced is ignoring the categoryID parameter.
For example, I want to find all auctions matching "1943" in the "Video Games" category (ID #1249). eBay instead returns a bunch of auctions for coins instead.
This is the URL I am using:
http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.13.0&SECURITY-APPNAME=AppID&GLOBAL-ID=EBAY-US&keywords=1943&categoryid=1249
Problem solved: I was using "categoryid" instead of "categoryId." (sigh)

eBay API GetCategory using CategoryName

Does ebay provide Category using CategoryName? I can get the Category using categoryid, but I want to get it using CategoryName
Something similar to the following URL, when I call an ebay api with category name it should give me the response of category.
http://open.api.ebay.com/Shopping?callname=GetCategoryInfo&appid=YourAppiD&siteid=3&CategoryName=Antiques&version=729
The reason this functionality isn't provided by eBay is: 1) it's not very specific, whereas a CategoryID is very specific; 2) there are many duplicate category names, like "Other", or time periods (1900-1949) that could refer to comic, coins, stamps, etc.

Should we always validate resource id in url and body in HTTP PUT request?

Suppose I am updating a employee record
url - /api/employees/10
body -
{
id : 10,
name : xyz
}
Should I validate for the employee id in url is same as in response? Because one employee can hit the url himself but update the data of another employee by sending another value in the PUT body.
If you have to validate, it's likely that you want to use POST. A POST is not idempotent and you are supposed to manage the change.
PUT is idempotent, and it just creates a resource. It implies that you don't actually care what id 10 is and whether it is a new id or an existing id. You just replace id 10 with the resource you supply. You only use PUT when you know what the uri should be.
Yes, if the representation of the object in the body contains its own key, you should validate that it matches the key from the URL. It's an error for the client to try to PUT an object at /api/employees/10 that isn't a valid value for employee #10's record, so you should check for that and report it as an error just as you would check that the object has correct syntax.
I believe that the best error code to return in this case is 422 Unprocessable Entity, but I might be wrong about that.
Another thing you can do instead is don't include the key at all in the body. However I find that keeping the key in makes sense for consistency with the way the same type of object is represented in other parts of the API (possibly embedded inside other objects). This is especially true when using XML (although it looks like you are using JSON here).