在我的应用程序中,我想通过 iPhone 应用程序在狂欢电子商务中订购产品。我很容易获得产品名称及其详细信息,但是在为产品创建订单时,它会在 html 页面中返回错误:
<h1>
TypeError
in Spree::Api::V1::OrdersController#create
</h1>
<pre>can't convert Symbol into Integer</pre>
我发送帖子请求为:
NSString *str = [NSString stringWithFormat:@"http://localhost:3000/api/orders"];
NSURL *urlForBuy = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:urlForBuy];
NSString *idVariant = [NSString stringWithFormat:@"order[line_items][%d][variant_id]",0];
NSString *qnty = [NSString stringWithFormat:@"order[line_items][%d][quantity]",0];
NSString *idVariantValue = @"123456";
[request setPostValue:[NSString stringWithFormat:@"%d",[idVariantValue intValue]] forKey:idVariant];
[request setPostValue:[NSString stringWithFormat:@"%d",1] forKey:qnty];
[request setPostValue:@"<my admin token>" forKey:@"token"];
[request setRequestMethod:@"POST"];
[request setDelegate:self];
[request setDidFinishSelector:@selector(buyResponse:)];
[request setDidFailSelector:@selector(buyResponse_failed:)];
[networkQueue addOperation:request];
[networkQueue go];
此外,我从 Spree 的 REST api 文档获得的这个网址是: http: //guides.spreecommerce.com/rest.html
另一件事我想知道这个 url 中的 [line_items] 是什么......另外,除了上面的 url 之外,他们是否还有任何教程?......提前致谢。