r/httr通行证列表以发布查询

发布于 2025-02-03 03:51:16 字数 1886 浏览 5 评论 0原文

我正在尝试使用url https:/https:/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
}

我正在使用以下查询,但是孩子们的参数是被忽略。如您所见,我已经进行了多次尝试,但无效。.

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}}

I am trying to query the tax calculator for my country using url https://swisstaxcalculator.estv.admin.ch/#/calculator/income-wealth-tax

Using browser inspector I know that the query should look something like this:

{
  "SimKey": null,
  "TaxYear": 2021,
  "TaxLocationID": 100000000,
  "Relationship": 1,
  "Confession1": 5,
  "Children": [
    {
      "Age": 6
    },
    {
      "Age": 11
    }
  ],
  "Confession2": 0,
  "TaxableIncomeCanton": 30000,
  "TaxableIncomeFed": 30000,
  "TaxableFortune": 0
}

I'm using the following query in R but the Children argument is ignored. As you can see I have made multiple attempts but none works..

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")

Can anybody help me figuring out how to pass the Children argument? Using the calculator manually I know the response should be as follows for this input:

{"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}}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

(り薆情海 2025-02-10 03:51:16

您必须将儿童年龄作为嵌套清单,从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

You have to pass the children ages as a nested list from within 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文