Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json_node_export API is different in NewCantus #1031

Closed
dchiller opened this issue Sep 13, 2023 · 4 comments
Closed

json_node_export API is different in NewCantus #1031

dchiller opened this issue Sep 13, 2023 · 4 comments

Comments

@dchiller
Copy link
Contributor

dchiller commented Sep 13, 2023

Discovered in the course of a subdiscussion of an unrelated issue and investigating the failing tests when Cantus Ultimus was modified to use links to NewCantus.

The json object returned by the json_node_export API (at least for sources) has a different structure in Old and NewCantus. See the export for source 123981 in OldCantus and NewCantus. It looks to me like the response from the OldCantus API is provided in the returned object at the key json_info and adds a bunch of other (at times duplicate) top-level keys.

I don't know how many entities other than Cantus Ultimus use this API, so it is fairly easy to adjust what we do to the new format. I would at least add a note to this effect in the wiki (since it seems like a lot to modify the API to conform to OldCantus without knowing anyone else is using it), as what is currently there makes it sound like you should just be able to point to the new url. Maybe to relevant entry add something like an italicized "Note: Field names in the response object have changed between the json-node API and this API."

A related side note: I see there are other issues (eg. #840, #564) in an ongoing discussion about this API endpoint and whether or not it is used, how and whether or not to update the API to work with the ID assignment scheme in NewCantus. Cantus Ultimus does need this API to obtain source metadata, but could, of course, switch to a new API if one were available in NewCantus. So, for one, I don't know when we will have a published source in NewCantus with an ID > 1000000, but as it currently stands we would need this API to support that source.

@dchiller dchiller changed the title json_node_export API returns unexpected 404 errors json_node_export API is different in NewCantus Sep 13, 2023
@dchiller
Copy link
Contributor Author

dchiller commented Sep 13, 2023

Another side note, this one unrelated: It seems that Drupal and Django handle duplicate slashes (/) in URLs differently. In OldCantus, https://cantus.uwaterloo.ca//json-node/123981 (note the two slashes after the domain) provides the same response as https://cantus.uwaterloo.ca/json-node/123981 while in NewCantus https://cantusdatabase.org//json-node/123981 leads to a 404 error. We had been using these malformed urls in Cantus Ultimus, so while they worked with the OldCantus domain, when we switched to the NewCantus base domain, they started failing.

I've changed CantusUltimus so that we don't send requests to these bad url's anymore (ie. the NewCantus behaviour seems correct to me) but thought it an funny find!

@jacobdgm
Copy link
Contributor

jacobdgm commented Sep 13, 2023

So the json_node_export API returns all the fields for the object in question. Some of our internal variable names are different from those on OldCantus, so the keys are different. I've added a note to this effect, as you suggested.

It looks to me like the response from the OldCantus API is provided in the returned object at the key json_info and adds a bunch of other (at times duplicate) top-level keys.

This is basically true - json_info stores the response we received from OldCantus during the syncing process, just in case we discover there's some important bit of information that wasn't fully imported from OldCantus after the old site is brought down. So the the value in json_info will be the same as the old json-node API (but if the chant has been edited on NewCantus, the value will be out of date. And if the chant was initially created on NewCantus, it won't have any json_info.

@jacobdgm
Copy link
Contributor

Now that the documentation/wiki has been updated (and since adding support for duplicate slashes is probably not necessary), I'm going to close this.

@dchiller
Copy link
Contributor Author

Thanks for the info. I've updated Cantus Ultimus accordingly. (And yes, don't support double slashes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants