printdotio / printio-api

Issues + wiki for the api. See http://print.io/api
0 stars 0 forks source link

What are the parameters supported by "Image": [{"Url": }] in orders/POST? #28

Open seanwooj opened 9 years ago

seanwooj commented 9 years ago

Hi again.

Working on my implementation of the API into my app and was wondering what the limitations were on the URL that can be entered for an image.

My app takes in a querystring at it's /generator.jpg path to generate an image on the fly. Down the line, i'd like to change way we generate images, but that'll be a while down the road. For now we would generate a really long image url with a bunch of parameters, so that the URL would look something like this:

"http://quotenote.herokuapp.com/generator.jpg?background_id=3&font_color=%23ffffff&font_family=cabin_sketch&full_size=true&quote_author=&quote_text%5B%5D=qffdsa+gaodigsjdog+iasdg+as%0D&quote_text%5B%5D=dg+asd+g&repeating=false"

Also that URL above doesn't work when I make a post to orders, but this one does: "http://quotenote.herokuapp.com/generator.jpg?background_id=19&font_color=%23ffffff&font_family=cabin_sketch&quote_author=&quote_text%5B%5D=type+my+quote+omg&quote_text%5B%5D=dg+asd+g&repeating=false&full_size=true"

I think it has to do with the fact that I'm generating a querystring from a hash of things, and some of those (the quote text) are an array of strings, which generates an interesting querystring

quote_text%5B%5D=type+my+quote+omg&quote_text%5B%5D=dg+asd+g

Where there are two query keys with the same name. I think that's what might be making the orders post fail. As far as I can tell, that's the only difference, and when I've pulled one of the parameters out, it has worked correctly.

Thanks for the help and sorry for the long request!

micahasmith commented 9 years ago

Normally when a POST fails it returns a detailed reason why, an error id, or both.

Can you send me what the result is for when you try to do this?

seanwooj commented 9 years ago

Here is the reference code 9e7d9161-48f9-4a34-953f-4a8aafbdd14b

Thanks a bunch!

micahasmith commented 9 years ago

How are you posting (form vs raw), and are you setting your Content-Type http headers and such?

From our side it looks like you're posting an empty body

seanwooj commented 9 years ago

I'm looking into this right now -- will let you know ASAP.

seanwooj commented 9 years ago

Hey Micah,

Thanks for letting me know about the empty body issue. Looked at my HTTP library and wasn't setting my content type to json, nor passing in parameters in JSON format. Looks like things are going through now. Much appreciated!

Sean

micahasmith commented 9 years ago

awesome!

seanwooj commented 9 years ago

Hey again,

Working on getting things running on our staging and production server. I've been running into a problem with image URLs that we're posting.

Here's the raw output

"{\"ShipToAddress\":{\"FirstName\":\"Sean\",\"LastName\":\"Test\",\"Line1\":\"2926 West Street\",\"City\":\"Oakland\",\"CountryCode\":\"US\",\"State\":\"CA\",\"PostalCode\":\"94608\",\"Phone\":\"9495212011\",\"Email\":\"seanwoojinkim@gmail.com\"},\"Items\":[{\"Quantity\":1,\"SKU\":\"ArtPoster-12x12\",\"ShipType\":\"Standard\",\"Images\":[{\"Url\":\"http://quotenote-staging.herokuapp.com/generator.jpg?background_id=1\\u0026font_color=%23ffffff\\u0026font_family=cabin_sketch\\u0026full_size=true\\u0026overlay=true\\u0026quote_author=bro\\u0026quote_text%5B%5D=i+don%27t+know+why+this+%0D\\u0026quote_text%5B%5D=isn%27t+working.\\u0026repeating=false\"}]}],\"Payment\":{\"PartnerBillingKey\":\"y93J5oFCUXmBFqnGJ8R5GRmyaspRHB4T8G4vU7M7aoc=\"},\"IsPreSubmit\":false,\"SourceId\":12}"

Here's the error reference code. 69484b5a-40d0-403f-99df-b2418fae42dd

This all works on my local development environment, but the urls it is generating are in the format http://localhost:3000/generate.jpg?query_parameters=parameters

on my staging and production environments they are in this format http://quotenote-staging.herokuapp.com/generate.jpg?query_parameters=parameters

I think the URL regex that you have doesn't like my URL. But I am just guessing.

Would appreciate any insight into the 500 error that I'm getting.

Thanks a ton, and sorry for so many posts.

seanwooj commented 9 years ago

got the same error today: {"ErrorReferenceCode"=>"d068e397-377b-4cc1-a159-e5119bcf5f43", "HadError"=>true}

Curious to get a more detailed understanding of what the error is from your perspective. Thanks!

micahasmith commented 9 years ago

@seanwooj can you replay and let me know?