tumblr / docs

Tumblr's public platform documentation.
Apache License 2.0
109 stars 27 forks source link

Neue post format layout not working #71

Closed asker26 closed 2 years ago

asker26 commented 2 years ago

Hello there! I'm getting an error while using tumblr API to post something vie neue post format. If I don't specify layout, everything's fine. However, the time I add it request throws 500 error. I've checked API documentation a lot of times, yet I can't find what I'm doing wrong and the error doesn't give much info to debug. Here's my code and the full error it returns:

                         $sendData[ 'content' ][] = [
                'type'  => 'image',
                'media' => [
                    'type' => 'image/jpeg',
                    'url'  => 'https://i.natgeofe.com/n/cfa19a0d-eff0-4628-8fdd-2ad8d66845dd/mountain-range-appenzell-switzerland_16x9.jpg'
                ]
            ];

            $sendData[ 'content' ][] = [
                'type'  => 'image',
                'media' => [
                    'type' => 'image/jpeg',
                    'url'  => 'https://i.natgeofe.com/n/cfa19a0d-eff0-4628-8fdd-2ad8d66845dd/mountain-range-appenzell-switzerland_16x9.jpg'
                ]
            ];

            $sendData[ 'layout' ] = [
                [
                    'type' => 'rows',
                    'display' => [
                        [ 'blocks' => [ 0, 1 ] ],
                    ]
                ]
            ];

{"meta":{"status":500,"msg":"Internal Server Error"},"response":[], "errors": [ { "title":"Internal Server Error", "code":0, "detail":"Something broke. Try again." } ] }

AprilSylph commented 2 years ago

It looks like there's only one content block here, but you're referencing two in your layout?

sndsgd commented 2 years ago

Having a look at this now. Sounds like you might have found a bug; we'd rather respond with a 400 if there is an issue in the request parameters. Thanks for the report!

asker26 commented 2 years ago

$sendData[ 'content' ][] = [ 'type' => 'image', 'media' => [ 'type' => 'image/jpeg', 'url' => 'https://i.natgeofe.com/n/cfa19a0d-eff0-4628-8fdd-2ad8d66845dd/mountain-range-appenzell-switzerland_16x9.jpg' ] ];

Sorry , I might have cut first part of my code when pasting here, but there's definitely two content blocks, here's a ss of my code:https://i.imgur.com/NJPEIdI.png

sndsgd commented 2 years ago

@Askerased after debugging this a bit, it would appear that the block indexes may have been decoded as strings if you were using form data or multipart content types to encode your request body. We just deployed a change that I believe should fix this issue. Can you please try your request again and let us know if you're able to create your post?

Also, it looks like there are various scenarios where validation errors related to malformed NPF data can result in a 500. We'll see if we can carve out some time to make improvements, but at the moment we cannot commit to a timeline for this work.

asker26 commented 2 years ago

Hi, I tried and it posted without a problem. Works perfectly now, thank you very much!