.net api 400 error on write

36 views
Skip to first unread message

jr...@unation.com

unread,
May 8, 2012, 9:58:02 AM5/8/12
to shopify-api
Hey Guys this is a sample of what i am doing.
Everytime I read everything works perfectly.
When I try to add i get a 400 error bad request.
Look at the second button click when i call save it throws a 400 any
help or ideas would be great.
referencing the shopify.dll

protected void b1_Click(object sender, EventArgs e)
{
string shopname =
Request.QueryString["storename"].ToString();

dynamic shopify = new Shopify.Api("x", "y", shopname);
var query = shopify.Products(collection_id: 7364815);


foreach (var product in query.products)
{
if (product.variants[0].sku == txt2.Text)
{
output.Text += "PRODUCT NAME = " + product.title;
output.Text += "<br/>";
output.Text += "PRICE = " +
product.variants[0].price;
output.Text += "<br/>";
output.Text += "SKU = " + product.variants[0].sku;
output.Text += "<br/>";
output.Text += "Quantity On Hand = " +
product.variants[0].inventory_quantity;
output.Text += "<br/>";
output.Text += " <img src=\"" +
product.images[0].src + "\">";
output.Text += "<br/>";
output.Text += "<br/>";
output.Text += "<br/>";
}
else
{
// output.Text = "";
}
}
}

protected void add_Click(object sender, EventArgs e)
{
var p = new { title = "My new Product", handle = "sex-
appeal" };

dynamic shopify = new Shopify.Api("x", "y", "z");
shopify.Products.Save(p);

}
}

jr...@unation.com

unread,
May 8, 2012, 10:05:01 AM5/8/12
to shopify-api

Edward Ocampo-Gooding

unread,
May 8, 2012, 10:06:49 AM5/8/12
to shopi...@googlegroups.com
No big deal here, but I recommend you post code snippets into a service like http://gist.github.com in the future so formatting, etc. is maintained and so that we don’t have to swim through a wall of text reading :)

Justin Ryan

unread,
May 8, 2012, 10:12:11 AM5/8/12
to shopi...@googlegroups.com

I posted it up there. Any idea why the 400 would come through do no not have the data object structured right?

John Duff

unread,
May 8, 2012, 10:15:08 AM5/8/12
to shopi...@googlegroups.com
Could you post the raw request (with headers) and the complete
response you are getting back?

John Duff
Software Developer @ Shopify.com

Justin Ryan

unread,
May 8, 2012, 10:21:46 AM5/8/12
to shopi...@googlegroups.com

Cory B

unread,
May 8, 2012, 11:13:17 AM5/8/12
to shopi...@googlegroups.com
I'm guessing the answer is right there: "The redirect_uri and application url must have matching hosts"

I'll bet your redirect_uri, which points to localhost, and your Return URL (specified in the shopify console) does not match.  Copy and paste your redirect_uri in to the field in the admin console.

-c

Justin Ryan

unread,
May 8, 2012, 11:17:10 AM5/8/12
to shopi...@googlegroups.com

Where in the admin console would that be set.

I am using a private app not a public one so I don’t know where I would set the Return URL

 

From: shopi...@googlegroups.com [mailto:shopi...@googlegroups.com] On Behalf Of Cory B
Sent: Tuesday, May 08, 2012 11:13 AM
To: shopi...@googlegroups.com
Subject: Re: .net api 400 error on write

 

I'm guessing the answer is right there: "The redirect_uri and application url must have matching hosts"

Justin Ryan

unread,
May 8, 2012, 11:18:38 AM5/8/12
to shopi...@googlegroups.com

Also the Read is working perfectly it is just the write throwing the exception.

 

From: shopi...@googlegroups.com [mailto:shopi...@googlegroups.com] On Behalf Of Cory B
Sent: Tuesday, May 08, 2012 11:13 AM
To: shopi...@googlegroups.com
Subject: Re: .net api 400 error on write

 

I'm guessing the answer is right there: "The redirect_uri and application url must have matching hosts"

colin

unread,
May 9, 2012, 2:10:54 PM5/9/12
to shopi...@googlegroups.com
The host in your web browser must match the host you're passing in the redurect_uri.

Are you using this adapter:  https://github.com/robconery/ShopifyApi  ?

Rob did mention to me that there were some parts not working.  If you go in and debug, maybe you can send over the fixes?

Justin Ryan

unread,
May 9, 2012, 2:12:26 PM5/9/12
to shopi...@googlegroups.com

Yea we had to recompile that api. The json response string was off miss a “;” ill recompile it and get it up to you guys with comments. Either way we got it running.

 

 

From: shopi...@googlegroups.com [mailto:shopi...@googlegroups.com] On Behalf Of colin
Sent: Wednesday, May 09, 2012 2:11 PM
To: shopi...@googlegroups.com
Subject: Re: .net api 400 error on write

 

The host in your web browser must match the host you're passing in the redurect_uri.

colin

unread,
May 9, 2012, 2:16:06 PM5/9/12
to shopi...@googlegroups.com
yea, please share!

Reply all
Reply to author
Forward
0 new messages