gpt4 book ai didi

ios - JSON POST 在 Poster/HTTP Client(Mac) 中工作正常,但在 XCode 中的 iOS 应用程序中工作不正常

转载 作者:行者123 更新时间:2023-11-29 04:38:30 25 4
gpt4 key购买 nike

我正在尝试将 JSON 内容发布到 Web 服务。它在 POSTER(firefox 插件)和 HTTP Client (Mac) 中运行良好。但尝试从 XCode(iOS 应用程序)进行 POST 时会抛出 500-内部服务器错误。有人可以帮我解决这个问题吗?

请求详细信息是:-

HTTP 方法:POST

内容类型:application/json

HTTP 正文:

{
"HasSunRoof" : "true",
"HasTiltWheel" : "true",
"VIN" : "XXXXXXXXXXXXXXX",
"VoluntarySignatureComments" : "Voluntary sign comments",
"Make" : "Audi",
"IsVinManuallyEntered" : "false",
"AssociatedCompanyId" : "2",
"ReposessionMethod" : "Voluntary with release",
"HasKeys" : "true",
"CreatedBy" : "RAMBO",
"InteriorCondition" : "Poor",
"HasPowerWindows" : "true",
"GlassCondition" : "Good",
"TransmissionType" : "Auto",
"EngineType" : "EngineType1",
"RecoveredFromAddress1" : "Myaddress1",
"CompanyId" : "1",
"HasPowerSeats" : "true",
"HasAirConditioning" : "true",
"Mileage" : "1243",
"HasCruiseControl" : "true",
"Trim" : "Trim data",
"HasRadio" : "true",
"HasSpares" : "true",
"FuelType" : "Alternative Fuel",
"IsDriveReady" : "true",
"TireCondition" : "Average",
"IsActive" : "false",
"CreatedOn" : "5\/24\/12",
"RecoveredFromAddress2" : "Myaddress2",
"IsRunnable" : "true",
"RecoveredFromState" : "Mystate",
"BodyStyle" : "Style1",
"RecoveredFromZip" : "90009",
"IsVoluntary" : "false",
"InteriorConditionDescription" : "Poor interiors",
"RecoveredFromCity" : "Mycity",
"Model" : "A6",
"Year" : "2009"
}

编辑:已解决请参阅下面对我的菜鸟错误的修复。

最佳答案

我现在可以成功发送请求了。我以错误的方式构建了 HTTP 请求,这对我来说很糟糕。

解决方案:对“Content-Type”、“Content-Length”等 http header 使用 setValue:forHTTPHeaderField:NOT setValue:forKey: p>

我想只要 key 是唯一的,我们是否使用它们中的任何一个都没关系。 但我错了

关于ios - JSON POST 在 Poster/HTTP Client(Mac) 中工作正常,但在 XCode 中的 iOS 应用程序中工作不正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10731985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com