試圖將嵌套參數的信息發佈到rails應用程序並遇到一些麻煩。使用ASIHTTPRequest使用NSDictionary對嵌套參數進行POST POST
#pragma mark - Begin Network Operations
- (void)beginNetworkOperation {
NSURL *requestURL = [NSURL URLWithString:[self retrieveURL]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:requestURL];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
[request setShouldContinueWhenAppEntersBackground:YES];
#endif
[request setRequestMethod:@"PUT"];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request addPostValue:strClientId forKey:@"client_id"];
[request addPostValue:strAccessToken forKey:@"access_token"];
NSDictionary *assetDictionary = [NSDictionary dictionaryWithObject:self.tags forKey:@"tags"];
[request addPostValue:assetDictionary forKey:@"asset"];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestFinished:)];
[request setDidFailSelector:@selector(requestFailed:)];
[request startSynchronous];
}
self.tags僅僅是一個逗號分隔值的NSString,但一旦到達軌道服務器標籤參數不能被讀取(PARAMS [:資產] [:標籤])。
我已經嘗試過了[請求addPostValue:[assetDictionary JSONRepresentation] forKey:@「asset」];我得到了同樣的錯誤在軌道服務器「TypeError(無法將符號轉換爲整數)」,這似乎毫無意義...... – Kyle
也許這是因爲你的字符串中的昏迷,因爲昏迷JSON的分隔符。 嘗試用別的東西代替你的刺中的昏迷,看看它是否工作 - stringByReplacingOccurrencesOfString:withString: – MatLecu
我的測試數據還沒有包含任何逗號。 – Kyle