All metafields fetched via Shopify API got improper owner and all belong to "shop" - json

I got problem with shopify API and with data it provides. When i try to get list of all meta-fields with my app I end up with invalid data that tell all meta-fields are owned by shop (owner_id, owner_resource in JSON result). In shop I work with there is over 2000 meta-fields, created mostly by installed apps, that most certainly belong directly to resources like page, blog or product and most of them are most certain not associated directly with shop.
What is more strange when i use chrome plugins or free shopify app to edit meta-fields, that in data i recieve present as associated with shop, they are displayed as belonging to particular aspects of shop as it should be. Adding or deleting meta-field does not reflect on the data or count of meta-fields I get in way explained below.
So what I do first is getting count of metafields with following request, to later know how split data requests into pages.
/admin/metafields/count.json
then to get complete set of data i make series of requests like this
/admin/metafields.json?limit=200&page=1
...
As result i get (example data)
{ "id": 2488777, "namespace": "content_value", "key": "[default]3883205", "value": "There are no items in your cart. ", "value_type": "string", "description": "", "owner_id": 2174481, "created_at": "2014-12-30T20:23:56+01:00", "updated_at": "2014-12-30T20:33:56+01:00", "owner_resource": "shop" }
So my question is what wrong I do here making these requests and why i get invalid data, or it is maybe another "shopify thing" to get such behaviour. Can someone direct me how to get full valid list of meta-fields with rightfully associated owners? Is there any caching involved with metafields that could cause lack of update?

When you make a call to /admin/metafields.json without any query parameters then you will see the metafields that belong to the shop.
You can retrieve metafields that belong to another resource by making an authenticated GET request to a URL like this one: /admin/orders/3250063171/metafields.json
An alternate format for the URL is this: /admin/metafields.json?metafield[owner_id]=3250063171&metafield[owner_resource]=order

Related

How to show Google FAQ structured data when there are quick navigation href=#XXX and id=XXX

I'm using valid FAQ structured data for some of my pages and it works fine on all pages which don't have quick navigation menu (page jumps with href=#XXX and id=XXX). For those with quick navigation the search result shows the quick navigation menu instead.
How should I make the FAQ SD with higher priority?
The homepage has structured data with multi top-level types Question. Each of these types is embedded in the property mainEntity. This way your data has multi properties mainEntity.
Check the value of this property from the documentation of Schema:
Indicates the primary entity described in some page or other
CreativeWork.
In my humble opinion, the phrase "primary entity" means that this property should be the only one in the data of the web page. This my opinion is confirmed by the following example from the Google guide for the type FAQ (link of the example):
{
"#context": "https://schema.org",
"#type": "FAQPage",
"mainEntity": [{
"#type": "Question",
"name": "What is the return policy?",
"acceptedAnswer": {
"#type": "Answer",
"text": "Most unopened items in new condition and returned within <strong>90 days</strong> will receive a refund or exchange. Some items have a modified return policy noted on the receipt or packing slip. Items that are opened or damaged or do not have a receipt may be denied a refund or exchange. Items purchased online or in-store may be returned to any store.<br /><p>Online purchases may be returned via a major parcel carrier. <a href='http://example.com/returns'> Click here </a> to initiate a return.</p>"
}
}, {
"#type": "Question",
"name": "How long does it take to process a refund?",
"acceptedAnswer": {
"#type": "Answer",
"text": "We will reimburse you for returned items in the same way you paid for them. For example, any amounts deducted from a gift card will be credited back to a gift card. For returns by mail, once we receive your return, we will process it within 4–5 business days. It may take up to 7 days after we process the return to reflect in your account, depending on your financial institution's processing time."
}
}, {
"#type": "Question",
"name": "What is the policy for late/non-delivery of items ordered online?",
"acceptedAnswer": {
"#type": "Answer",
"text": "Our local teams work diligently to make sure that your order arrives on time, within our normal delivery hours of 9AM to 8PM in the recipient's time zone. During busy holiday periods like Christmas, Valentine's and Mother's Day, we may extend our delivery hours before 9AM and after 8PM to ensure that all gifts are delivered on time. If for any reason your gift does not arrive on time, our dedicated Customer Service agents will do everything they can to help successfully resolve your issue. <br/> <p><a href='https://example.com/orders/'>Click here</a> to complete the form with your order-related question(s).</p>"
}
}, {
"#type": "Question",
"name": "When will my credit card be charged?",
"acceptedAnswer": {
"#type": "Answer",
"text": "We'll attempt to securely charge your credit card at the point of purchase online. If there's a problem, you'll be notified on the spot and prompted to use another card. Once we receive verification of sufficient funds, your payment will be completed and transferred securely to us. Your account will be charged in 24 to 48 hours."
}
}
]
}
In this example, you can see that all questions are embedded in only one property mainEntity.
This example is in JSON-LD format which you can convert to microdata (as it is in your data) using this free tool online RDF Translator.
However, I dare say that the microdata format has a rather strong dependence on the source code in which this data is installed. The homepage of your website has invalid HTML and critical errors such as Duplicate ID. Check the following information from W3:
Syntax errors: Certain invalid syntax constructs, when parsed, result
in DOM trees that are highly unintuitive. Sometimes it is really hard
to pick up the structured data when the HTML is broken completely.
This invalid HTMLL may interfere with web page rendering.

Google Classroom API Create Material

I am aware that there are multiple questions essentially asking the same thing, but part of the problem I've identified is a lack of detail in the questions, so I'm going to try here, since I think I've exhausted all possibilities.
In the newer Google Classroom, there is a Classwork Tab/Page. This is new, and replaced an older "About" page. In this page, as a regular web user, you can create various materials, including one simply called "Material." This is done by clicking the create button and choosing "Material".
These materials contain any combination of title, description, and attached files/links.
However, when using the API, while I can access any OTHER type of Classwork via:
Classroom.Courses.CourseWork, no attempts to find these items (or create them via the API) has been successful. I've successfully created Assignments (a variant of CourseWork using:
Classroom.Courses.CourseWork.create({
"creatorUserId":'me',
"state":'draft',
"courseId":cid,
"title":'test item',
"workType":"ASSIGNMENT",
"materials": [],
}, 'myClassCode');
}
The enum for workType according to the API only contains:
I've tried omitting the workType (receive error saying I need to include it), using various guesses like MATERIAL, NONE, ABOUT, and null (all receive errors for invalid types).
I can query the list of CourseWork and find all of my entries that are questions or assignments but have found no access to the other items, which are current and active in the Classwork page for the class.
It's possible that this simply isn't accessible via the API, but I'd like to confirm. Any advice would be appreciated.
I am running as SuperUser and everything else seems to be working fine.
You are right, at the moment it is not possible to create course materials through Google Classroom API.
Indeed, there is a feature request for it already:
https://issuetracker.google.com/issues/127591179
I suggest you to give it a star to increase visibility and get updates on the implementation status of the feature.
Here is code that I have been using
/------------------------------Create Coursework Material-----------------------------------
function createCourseworkMaterial (id, cTitle, cDescription, topicId) {
var courseArgs = {
"title": cTitle,
"description": cDescription,
"state" : "DRAFT",
"topicId": topicId
};
try{
Classroom.Courses.CourseWorkMaterials.create(courseArgs,id);
}catch(e){
console.error('Classroom.Courses.CourseWorkMaterial.create() yielded an error: ' + e);
}
}

Should the server respond one json for all content data on the page in SPA or is better to split it?

I'm building API for SinglePageApplication, which handle by Angular in frontend. One thing is not clear to me.
Supose the web applcation has delati journal paige wich display journal,some articles which belongs to this journal and some cool authors which can be not connected to this journal.
Should I build my api urls based on each need page content, for example:
from url /api/journal/<journal_id>
send json:
{
"journal": {
"id": 10,
"name": "new_journal",
"articles": [
{
"name": "cool_article",
"id": 42
},
{
"name": "another_cool_article",
"id": 43
}
]
},
"authors": [
{
"name": "some_name",
"id": 42
},
{
"name": "another_name",
"id": 43
}
]
}
Or I should build my api based on concrete objects and related objects of them.
With urls like this:
/api/journals/<journal_id>
/api/authors/
And frontend side build this page with two GET requests for fetching content.
Sory if my question too broad, I just want to find best bractice for building API to SinglePageApplications.
Does it have any difference of building API enpoints for external web-apps and what I should do if page need to display more objects, which not belong together? Which of the options above is better?
There isn't really a universal right answer for this. It largely depends on the use case for that data you're fetching. I would say to err on the side of splitting this into multiple requests as it grants you flexibility and efficiency in terms of partial updates to the page. That approach also makes exposing an API to the public much easier in terms of being able to just expose what you already have.
If you're dealing with a potentially large (an intentionally relative term) number of concurrent requests though, you may build some composites of related data to mitigate that.
Of course, you could also do a combination of the two as well (first load makes 1 large request, subsequent updates are segmented).

Get data from Instagram API from confirmed project

I have two projects linked to one clientID. Project "A" is in sandbox, the "B" one is confirmed. I was calling feed with this type of URL
https://api.instagram.com/v1/users/[userID]/media/recent/?client_id=[clientID]&count=20&access_token=[mySecretToken]
The problem is, that with this type of URL I can retrieve data only for project A. For confirmed project B I always get an error
{"meta": {"error_type": "APINotFoundError", "code": 400, "error_message": "this user does not exist"}}
I'm following the documentation ( https://www.instagram.com/developer/endpoints/users/#get_users_media_recent ) but this absolutely doesn't work outside the sandbox!
In another part of documentation I have found this:
For example, if you query the /users/{user-id}/ endpoint and the {user-id} is a sandbox user, then you will get the normal API response; but if the {user-id} is not a sandbox user, you will get a APINotFound error.
That's really useful information, but I really can' find a way, how can I retrieve data from confirmed (live, reviewed) project.
Can plz anyone help how can I do it?

What is "redirects" in the Spotify JSON lookup API?

I'm working with the Spotify public lookup API and I just stumbled into something weird.
A JSON lookup for track 4y47sHvLLLX542a4NrBZqR returns the following (amended for conciseness):
{
track: {
redirects: [
"spotify:track:4y47sHvLLLX542a4NrBZqR"
],
href: "spotify:track:496AcgphC6MqkWas0suAfN",
...
},
...
}
Now, two things look weird in this response:
The returned href does not match the ID used for the lookup (496AcgphC6MqkWas0suAfN vs. 4y47sHvLLLX542a4NrBZqR)
There's an additional redirects array which I've never seen before
Another lookup for the track referenced in href returns the same exact JSON, but without redirects.
Does anyone know what this means? I assume there was some ID re-assignment in the history of that track and both versions were maintained for backwards compatibility, but I'd love to hear from someone with a more solid understanding of the API.
I assume there was some ID re-assignment in the history of that track and both versions were maintained for backwards compatibility.
Correct enough. Tracks can be redirected to other tracks for various reasons, the most common being when a track is unplayable in a user's locale but a functionally identical track is available. Seeing redirects like this in a context-less environment (i.e., one without a logged-in user) like the lookup API is rare, but as you've seen it can happen.