REST API Update not working

71 views
Skip to first unread message

Darren Bowers

unread,
Jun 2, 2021, 6:18:46 PMJun 2
to Gallery 3 Users
Hi All,

I am trying to do some bulk updates via REST API on a Gallery 3.1.3 (X-Gallery-API-Version 3.0) but it doesn't seem to be working as expected. I am using Postman to test the requests before I code them in python.

The GET requests are working fine, so the auth keys are good and the API is responding.

When I try to do a simple update using POST "put" of the enity title I get a 200 OK response with a null payload but the update doesn't work when I GET the item. I'm also checking the live site and its definitely not updating.

This is what the HTTP request looks like:

POST /gallery/index.php/rest/item/1016 HTTP/1.1
Host: www.mysite.com
X-Gallery-Request-Method: put
X-Gallery-Request-Key: [...]
Content-Type: application/x-www-form-urlencoded
Cookie: g3sid=[...]
Content-Length: 62
entity=%7B%22title%22%3A%22This%20is%20the%20new%20title%22%7D

200 OK
<null>

Any ideas what else I need to do to get the REST update working?

Thanks
Darren

J.R.

unread,
Jun 2, 2021, 7:27:06 PMJun 2
to gallery...@googlegroups.com, Darren Bowers
Darren,

Wow... what you are doing and the issue(s) you're having are so far outside of my knowledge base and skill set that I can only wish you the best of luck in being able to resolve this!

Let us know what transpires...

-- J.R.
--
WHEN USING AN EMAIL PROGRAM to reply to this message, click REPLY TO LIST or REPLY TO ALL so your reply goes out to everyone in the group. If you click REPLY or REPLY TO SENDER Google will *only* send your reply to the original author (not recommended).
 
To post a NEW MESSAGE to the group, send an new email to:
gallery...@googlegroups.com
 
To view or sign in to this group on the web, use this URL:
https://groups.google.com/forum/#!forum/gallery-3-users
---
You received this message because you are subscribed to the Google Groups "Gallery 3 Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gallery-3-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gallery-3-users/acab5c31-6de8-47d1-910e-a404e9f2fb76n%40googlegroups.com.

Brad Dutton

unread,
Jun 2, 2021, 8:16:23 PMJun 2
to Gallery 3 Users
Check for errors in the gallery/var/logs directory, see if there is any indication as to the problem.

Darren Bowers

unread,
Jun 2, 2021, 8:45:05 PMJun 2
to gallery...@googlegroups.com
Hi Brad, 

I just tested it now for the first time today and I saw the new log file created for /var/logs/2021-06-03.log.php but it was empty (i.e. only contained the PHP directive at the top)

Thanks
Darren

You received this message because you are subscribed to a topic in the Google Groups "Gallery 3 Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gallery-3-users/pkAOHGalh0w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gallery-3-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gallery-3-users/80b8e363-f0a5-4190-87ff-d505436cd2d1n%40googlegroups.com.

Darren Bowers

unread,
Jun 3, 2021, 8:03:51 PMJun 3
to gallery...@googlegroups.com
I tried changing the Log Threshold to DEBUG in the config.php ($config["log_threshold"] = 4;) but I don't see any additional output in the Logs - is there another way to activate debug in Gallery/Kohana?
Thanks
Darren

J.R.

unread,
Jun 7, 2021, 9:00:16 PMJun 7
to gallery...@googlegroups.com
Darren,

Something just occurred to me: The last time this process you are trying worked, was your Gallery server running in PHP 7 or higher? If you are currently running under PHP 7+ now that may be preventing the bulk transactions from being completed (and so not errors would show up in the Log file). There are a lot of new security-oriented aspects to PHP 7... and even more by the time they released PHP 7.4...

I only mention this because you said "
When I try to do a simple update using POST "put" of the entity title I get a 200 OK response" but the updates are not completing. Seems like you are being allow to make GET request but not being allowed to fully implement the POST put function to completion.

-- J.R.

Darren Bowers

unread,
Jun 7, 2021, 10:52:50 PMJun 7
to gallery...@googlegroups.com
Hi JR - I just checked and the server is running PHP 5.6. I can adjust this using cpanel from 4.4 to 8.0.

I have never attempted this before, so I'm happy to swap out some configs if that might help. I'm upgrading directly from an old 1.X version of Gallery that finally broke due to a mandatory PHP upgrade (I think). I have extracted all the old DAT database entries using python and now I just want to apply them to the 100's of photos in the gallery using the API and python.

Right now I've got the mariadb and gallery3 docker images and I'm going to attempt some caveman debugging. My PHP is very rusty so any tips would be welcome ;-)

Cheers
Darren


You received this message because you are subscribed to a topic in the Google Groups "Gallery 3 Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gallery-3-users/pkAOHGalh0w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gallery-3-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gallery-3-users/47433716-706b-f10b-b58a-406395c90308%40thepostalzone.com.

J.R.

unread,
Jun 11, 2021, 1:54:25 AMJun 11
to gallery...@googlegroups.com, Darren Bowers
After pushing "send" I did find a couple of references provided by Adrian London on how to migrate from Gallery 1 to Gallery 2. Since your Gallery 1 installation is not running I don't know if they will help, but there is quite a bit of detail in them which might give you some clues:

https://web.archive.org/web/20060219173204/http://codex.gallery2.org/index.php/Gallery2:migration

and

http://gallery.menalto.com/forum/68.html

-- J.R.

Darren,

Oops. I guess I missed where you described that you are trying to do this starting with the data from an ancient, non-working version of Gallery 1. The thing is, the database structures of Gallery 2 and Gallery 3 are totally different from the data storage structure of Gallery 1. In fact Gallery 1 did not use a "database" as we think of MySQL-type databases. It used a "flat file" system to store and retrieve data. As far as I know there was never an official process to upgrade Gallery 1 to Gallery 2, much less Gallery 3. If someone knows otherwise, please speak up.

I never used Gallery 1 or Gallery 2 so I am no expert, but it seem to me that even though you have extracted the old data entries from the Gallery 1 files, I don't see how they can be be put directly into the totally different SQL database structure of Gallery 3 -- unless you are only talking about pure text entries of descriptions/comments. Even then, the data fields where those things were stored in Gallery 1 are not likely not the same fields where those entries would be in the Gallery 3 database tables.

There is a page with a lot of information about the differences between Gallery 1 and Gallery 2, which might provide some insight:

http://codex.galleryproject.org/G1-G2_Comparison.html

A final note: Since Gallery 3.1.3 will run on a server running PHP 5.6, you should keep your server running 5.6 unless forced to change because everyone trying to upgrade from Gallery 2 has found that it has to be done under PHP 5.6 and only when the migration to Galley 3 is working correctly do you go ahead and change the server to run PHP 7.2 or PHP 7.4  (7.4 is now the official recommended version of PHP because of security issues with 7.1 and 7.2).

-- J.R.

J.R.

unread,
Jun 11, 2021, 1:54:25 AMJun 11
to gallery...@googlegroups.com, Darren Bowers
Darren,

Oops. I guess I missed where you described that you are trying to do this starting with the data from an ancient, non-working version of Gallery 1. The thing is, the database structures of Gallery 2 and Gallery 3 are totally different from the data storage structure of Gallery 1. In fact Gallery 1 did not use a "database" as we think of MySQL-type databases. It used a "flat file" system to store and retrieve data. As far as I know there was never an official process to upgrade Gallery 1 to Gallery 2, much less Gallery 3. If someone knows otherwise, please speak up.

I never used Gallery 1 or Gallery 2 so I am no expert, but it seem to me that even though you have extracted the old data entries from the Gallery 1 files, I don't see how they can be be put directly into the totally different SQL database structure of Gallery 3 -- unless you are only talking about pure text entries of descriptions/comments. Even then, the data fields where those things were stored in Gallery 1 are not likely not the same fields where those entries would be in the Gallery 3 database tables.

There is a page with a lot of information about the differences between Gallery 1 and Gallery 2, which might provide some insight:

http://codex.galleryproject.org/G1-G2_Comparison.html

A final note: Since Gallery 3.1.3 will run on a server running PHP 5.6, you should eep your server running 5.6 unless forced to change because everyone trying to upgrade from Gallery 2 has found that it has to be done under PHP 5.6 and only when is working correctly change the server to run PHP 7.2 or PHP 7.4  which is now the official recommended version of PHP because of security issues with 7.1 and 7.2).

-- J.R.

Darren Bowers

unread,
Jun 21, 2021, 7:44:55 AMJun 21
to Gallery 3 Users
Hi J.R. & Brad
Appreciate your help on this but I ended up ditching the REST API and using Python & MySQL to redo all of the image descriptions and titles from a master JSON file I extracted from the old Gallery 1.x DAT files.
Python + SQL was actually a huge load easier than crafting the REST POST requests in Python to be honest, so I'm kind of glad the REST API was playing up.
If anyone is interested in how I ported 1000+ images with custom fields from Gallery 1.X to 3.1.3, I'm happy to share some of the details and Python code. There was quite a bit of hacky Python, Regex, JSON and SQL but it still seemed way easier (and more fun) IMO than the G1 > G2 > G3 migration process or doing it by hand ;)
Cheers
Darren

J.R.

unread,
Jun 22, 2021, 1:04:32 AMJun 22
to gallery...@googlegroups.com
Darren,

Congratulations on pulling this of! I don't think going the G1>G2>G3 method would have worked. Too many things are different between the 3 generations of Gallery code and their respective databases to trip the process up. It would be great if you could post your code in a message(s) to the list. Someone will almost certainly find it very helpful... if not today then at sometime in the future when the next person comes along with a similar problem and joins this group. If that isn't practical perhaps you could create a zip or tar file containing the code and provide us with a link to where it can be downloaded? The google groups security system will not allow the posting of zip or tar files attached to a regular group message. It would also be very helpful if you could describe how you extracted the original G1 DAT files.

-- J.R.
Reply all
Reply to author
Forward
0 new messages