-1
この関数に次のjsonを渡す必要があります。そのため、Shopify Apiは送信を理解することができます。私は正しい変数のフォーマットを作成することができませんし、server.ShopifyのAPIに渡し、次のJSONが渡されることを期待しているPOSTAPIへのjsonパラメータのポストメソッドの使用Swift 3
経由この関数に次のjsonを渡す必要があります。そのため、Shopify Apiは送信を理解することができます。私は正しい変数のフォーマットを作成することができませんし、server.ShopifyのAPIに渡し、次のJSONが渡されることを期待しているPOSTAPIへのjsonパラメータのポストメソッドの使用Swift 3
経由あなたのAPIのURLで
をREQUEST_URLを交換し、あなたとJSON_STRING置き換え実際のJSON文字列
var request = URLRequest(url: URL(string: "REQUEST_URL")!)
request.httpMethod = "POST"
let postString = "JSON_STRING"
request.httpBody = postString.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else { // check for fundamental networking error
print("error=\(error)")
return
}
if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 { // check for http errors
print("statusCode should be 200, but is \(httpStatus.statusCode)")
print("response = \(response)")
}
let responseString = String(data: data, encoding: .utf8)
print("responseString = \(responseString)")
}
task.resume()
あなたのオブジェクトが辞書に変換してから
ことによってそれをシリアル化
parthは私のjson文字列を 'let poststring = "Json_strong"の中に設定する方法を教えてくれますか? –
あなたはデータまたはオブジェクトのjson Stringを持っていますか? –
オブジェクトparth brother –