lildude / phpSmug

:camera: phpSmug is a simple object orientated wrapper for the new SmugMug API v2, written in PHP.
https://lildude.github.io/phpSmug
MIT License
42 stars 19 forks source link

400 Error code creating album, please help. #57

Closed davidvexel closed 5 years ago

davidvexel commented 5 years ago

Has anyone had 400 Bad Request errors when creating albums?

This is my code

try {
    // Create
    $album = $client->post( $endpoint, $options );
    return $album;
 } catch ( BadResponseException $ex ) {
    var_dump( $ex->getResponse()->getBody()->getContents() ); 
}

This is my request data:

  'UrlName' => string 'wp-smugmu-local-test-32' (length=23)
  'Name' => string 'Test' (length=4)
  'Privacy' => string 'Public' (length=6)
  'Description' => string 'Album published from a WP Gallery in smugmug website.' (length=54)

This is my endpoint /api/v2/folder/user/myuser/January-2019!albums

And I'm getting this error:

{"Response":{"Uri":"/api/v2/folder/user/myuser/January-2019!albums?_verbosity=1","Locator":"Album","LocatorType":"Objects"},"Code":400,"Message":"Bad Request"}

Any ideas?

Thanks in advance!

davidvexel commented 5 years ago

If I change the UrlName to WP-chico-local-test-smugmug-324 works. lol.

davidvexel commented 5 years ago

Seems like the wp lowercase letters doesn't like to UrlName param, it only works if I use them as uppercase WP... Very odd. Closing this issue for now. Thanks.

danielmreck commented 5 years ago

@davidvexel, I believe that SmugMug folders, galleries, and pages are required to start with a number or a capital letter.

The on the live site, SmugMug site will rewrite HTTP requests for folders, galleries, and pages that start with a lowercase letter to make them start with uppercase. However, the rest of the URL will still pay attention to case.

As such, example.com/January-2019/wP-chico-local-test-smugmug-324 will resolve to example.com/January-2019/WP-chico-local-test-smugmug-324 and display your gallery. But example.com/January-2019/wp-chico-local-test-smugmug-324 will throw a 404 error.

I do not believe the API will correct for lowercase initial letters on requests.

davidvexel commented 5 years ago

Hey @danielmreck, you're so right, I didn't know about this and made me struggle for a bit, thanks you!