我正在嘗試使用網址https://swisstaxcalculator.estv.admin.ch/#/calculator/income-wealth-tax查詢我所在國家/地區的稅收計算器
使用瀏覽器檢查器我知道查詢應該是這樣的:
{
"SimKey": null,
"TaxYear": 2021,
"TaxLocationID": 100000000,
"Relationship": 1,
"Confession1": 5,
"Children": [
{
"Age": 6
},
{
"Age": 11
}
],
"Confession2": 0,
"TaxableIncomeCanton": 30000,
"TaxableIncomeFed": 30000,
"TaxableFortune": 0
}
我在 R 中使用以下查詢,但 Children 引數被忽略。如您所見,我進行了多次嘗試,但都沒有成功..
url <- https://swisstaxcalculator.estv.admin.ch/delegate/ost-integration/v1/lg-proxy/operation/c3b67379_ESTV/API_calculateSimpleTaxes
httr::POST(url,
body = list(
SimKey = NULL,
TaxYear = 2021,
TaxLocationID = 100000000,
Relationship = 1,
Confession1 = 5,
# Children = list("Age" = 6, "Age" = 11),
# Children = array(c(6,11), dimnames = list(c("Age", "Age"))),
Children ='[{Age:6,Age:11}]',
Confession2 = 0,
TaxableIncomeCanton = 30000,
TaxableIncomeFed = 30000,
TaxableFortune = 0
),
encode = "json")
誰能幫我弄清楚如何通過孩子的論點?手動使用計算器我知道這個輸入的回應應該如下:
{"response":{"IncomeSimpleTaxCanton":1138,"FortuneTaxCanton":0,"IncomeSimpleTaxCity":1138,"IncomeTaxChurch":0,"IncomeTaxCity":893,"IncomeSimpleTaxFed":0,"PersonalTax":0,"FortuneTaxCity":0,"FortuneSimpleTaxCanton":0,"IncomeTaxFed":0,"FortuneSimpleTaxCity":0,"IncomeTaxCanton":1763,"Location":{"TaxLocationID":100012001,"ZipCode":"1000","BfsID":5586,"CantonID":23,"BfsName":"Lausanne","City":"Chailly-sur-Laus","Canton":"VD"},"FortuneTaxChurch":0}}
uj5u.com熱心網友回復:
您必須將孩子的年齡作為嵌套串列從 R 中傳遞:
url <- "https://swisstaxcalculator.estv.admin.ch/delegate/ost-integration/v1/lg-proxy/operation/c3b67379_ESTV/API_calculateSimpleTaxes"
resp <- httr::POST(url,
body = list(
SimKey = NULL,
TaxYear = 2021,
TaxLocationID = 100000000,
Relationship = 1,
Confession1 = 5,
Children = list(list(Age = 6), list(Age = 11)),
Confession2 = 0,
TaxableIncomeCanton = 30000,
TaxableIncomeFed = 30000,
TaxableFortune = 0
),
encode = "json")
content <- httr::content(resp, encoding = "UTF-8", as = "text")
jsonlite::fromJSON(content)
#> $response
#> $response$IncomeSimpleTaxCanton
#> [1] 1138
#>
#> $response$FortuneTaxCanton
#> [1] 0
#>
#> $response$IncomeSimpleTaxCity
#> [1] 1138
#>
#> $response$IncomeTaxChurch
#> [1] 0
#>
#> $response$IncomeTaxCity
#> [1] 893
#>
#> $response$IncomeSimpleTaxFed
#> [1] 0
#>
#> $response$PersonalTax
#> [1] 0
#>
#> $response$FortuneTaxCity
#> [1] 0
#>
#> $response$FortuneSimpleTaxCanton
#> [1] 0
#>
#> $response$IncomeTaxFed
#> [1] 0
#>
#> $response$FortuneSimpleTaxCity
#> [1] 0
#>
#> $response$IncomeTaxCanton
#> [1] 1763
#>
#> $response$Location
#> $response$Location$TaxLocationID
#> [1] 100000000
#>
#> $response$Location$ZipCode
#> [1] "1000"
#>
#> $response$Location$BfsID
#> [1] 5586
#>
#> $response$Location$CantonID
#> [1] 23
#>
#> $response$Location$BfsName
#> [1] "Lausanne"
#>
#> $response$Location$City
#> [1] "Lausanne"
#>
#> $response$Location$Canton
#> [1] "VD"
#>
#>
#> $response$FortuneTaxChurch
#> [1] 0
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/487502.html
下一篇:在django中更改影像名稱
