标签: request

如何在 JSON 响应中断言具有多个属性的 JSON

我的服务器在 Postman 中返回 JSON 响应,其形式如下:

     {
       "accountType": "CHECKING",
       "message": "Your account is overdrawn",
       "withdrawalCode": 'SZWW-2000-11-CD'
    }
Run Code Online (Sandbox Code Playgroud)

我正在像这样使用 Cypress 发送请求,并尝试断言所有字段。这是我的尝试


      cy.request({
        method: 'POST',
        url: 'http://users/bank-account/withdrawal', 
        body: {     
          name: "paul.king@asher-bank.com",
          password: "test123"
        },
        failOnStatusCode:false
     }).its('body')
       .should('have.property', 'accountType', 'Checking')
       .should('have.property', 'message','User with withdrawal ref: \'CCR-001-009-GG\' is overdrawn')
       .should('have.property', 'withdrawalCode','SZWW-2000-11-CD')
    })

Run Code Online (Sandbox Code Playgroud)

这 3 个属性中只允许第一个属性断言。其他2个是不允许的。我如何断言多个属性。

request mocha.js end-to-end cypress

0
推荐指数
1
解决办法
266
查看次数

你应该在MySQL请求中引用数字吗?

什么是更专业和错误证明方法与简单的mysql而不是PDO或任何东西

我通常喜欢这样

    $sql_request = "SELECT * 
                      FROM myusers 
                          WHERE user_id = {$user_id} 
                            AND email = '{$email_address}' 
                              LIMIT 0,1";
Run Code Online (Sandbox Code Playgroud)

不过我应该引用{$user_id}一下吗?

即使我得到用户输入我也不引用数字,但是在处理之前我会检查ctype_digit().

php mysql request

-1
推荐指数
1
解决办法
1034
查看次数

什么是价值阴影?

  1. 嗨,大家好

            private const string abc="__abc";
            private const string abcd="__abcd";
    
    
            pageLoad()
            {
            this.xyz();
            }
    
            xyz()
            {
            if postback()
            {
            }
            else
            {
            string k1=this.Request[abc];//some 'value shadowing error is           shown here by my tool . This makes it
    
    Run Code Online (Sandbox Code Playgroud)

    不安全且容易受到用户编辑的影响。string k2=this.Request[abcd];// } }

        I want to resolve this issue but I am unsure about where to begin?
    
         - List item
    
    Run Code Online (Sandbox Code Playgroud)

c# security request fortify

-1
推荐指数
1
解决办法
4766
查看次数

Laravel 5.2我怎样才能获得像$ _POST这样的帖子数据?

我尝试过$request->all();,$request->input();但都包括$_GET数据.

如何只$_POST使用Laravel 检索数据?

request laravel

-1
推荐指数
1
解决办法
3444
查看次数

SQLSTATE [01000]:警告:1265列的数据被截断

SQLSTATE [01000]:警告:1265第一行的列“ pay_totals”数据被截断

public function order(Request $req){
        $order = new Order;
        $order->pay_number = $req->checkout_number;
        $order->pay_totals = $req->checkout_total;
        $order->save();
        return redirect(route('pay'))->with('message','Sending infomation successfully');
    }
Run Code Online (Sandbox Code Playgroud)

刀:

<input type="text" name="checkout_total" value="{{Cart::subTotal('0') }} ">
Run Code Online (Sandbox Code Playgroud)

Helppp

mysql sql request laravel

-1
推荐指数
4
解决办法
3万
查看次数

在Python中,如何检测网站是否已关闭?

换句话说,如果它返回200,则打印True.否则,错误.

我怎么能检测出来?

谢谢.

python http request

-2
推荐指数
1
解决办法
191
查看次数

如何使用数组正确格式化 JSON

我正在尝试在我的 POST 请求中发送一个 JSON 有效负载,但我不确定如何正确格式化它以使用数组。下面是正确的 JSON本身的样子:

{
    "animal": "dog",
    "contents": [{
        "name": "daisy",
        "VAL": "234.92133",
        "age": 3
    }]
}
Run Code Online (Sandbox Code Playgroud)

到目前为止我有这个:

        group := map[string]interface{}{
            "animal": "dog",
            "contents": map[string]interface{}{
                "name": "daisy",
                "VAL":  "234.92133",
                "age":  3,
            },
        }
Run Code Online (Sandbox Code Playgroud)

但我无法弄清楚如何处理内容数组(方括号),只有“内容”中的大括号。

arrays json http request go

-2
推荐指数
1
解决办法
38
查看次数

测试后反应cypress json-server恢复到原始数据库

嘿,我正在用 cypress 测试 React 应用程序,并使用 json-server 来测试一个假 api。

当我运行一些测试时,它将更改我的 db.json 文件的数据库。

因此计划是在每次测试后将数据库恢复到原始状态。

这是我的代码:

describe('Testing fake db to be restored to original database after 
updating it in other test', () => {

 let originalDb: any = null

    it('Fetch the db.json file and then updating it to the original copy', 
       () => {

      // Save a copy of the original database
      cy.request('GET', 'localhost:8000/db').then(response => {
         originalDb = response;
         console.log(originalDb);
       })

    // Restore the original database
    cy.wrap(originalDb).then(db => {
      cy.request({
        method: 'PUT',
        url: …
Run Code Online (Sandbox Code Playgroud)

testing request reactjs json-server cypress

-2
推荐指数
1
解决办法
184
查看次数

将数据从JSP页面传递到MULTIPLE JSP页面

如何将多个用户条目从一个JSP传递到其他JSP页面?示例I在不同的输入框中输入数字2,3,4,5,然后点击提交.我知道在下一页,数字会在那里,但在第三页,他们不会.

谢谢!

html java session jsp request

-3
推荐指数
1
解决办法
7790
查看次数

python请求带有标头和参数的POST

我有一个发帖请求,试图requests在python中发送。但是我收到无效的403错误。请求可以通过浏览器正常运行。

POST /ajax-load-system HTTP/1.1
Host: xyz.website.com
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-GB,en;q=0.5
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Referer: http://xyz.website.com/help-me/ZYc5Yn
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 56
Cookie: csrf_cookie_name=a3f8adecbf11e29c006d9817be96e8d4; ci_session=ba92hlh6o0ns7f20t4bsgjt0uqfdmdtl; _ga=GA1.2.1535910352.1530452604; _gid=GA1.2.1416631165.1530452604; _gat_gtag_UA_21820217_30=1
Connection: close

csrf_test_name=a3f8adecbf11e29c006d9817be96e8d4&vID=9999
Run Code Online (Sandbox Code Playgroud)

我在python中尝试的是:

import requests
import json

url = 'http://xyz.website.com/ajax-load-system'

payload = {
'Host': 'xyz.website.com',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Language': 'en-GB,en;q=0.5',
'Referer': 'http://xyz.website.com/help-me/ZYc5Yn',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With': 'XMLHttpRequest',
'Content-Length': '56', …
Run Code Online (Sandbox Code Playgroud)

python post request python-3.x python-requests

-3
推荐指数
1
解决办法
2万
查看次数

无法推迟关闭请求正文

知道为什么我无法关闭请求正文吗?请求返回200且没有错误,但是req.Body.Close()抛出运行时错误:无效的内存地址或nil指针取消引用

clientHttp := &http.Client{}

req, err := http.NewRequest("GET", "https://example.com/item/"+strconv.FormatInt(itemID, 10), nil)
  if err != nil {
    logrus.Error(err)
    return models.Company{}, err
  }
resp, err := clientHttp.Do(req)
 if err != nil {
    logrus.Error(err)
    return models.Company{}, err
 }

defer req.Body.Close() // <- panic!
Run Code Online (Sandbox Code Playgroud)

request go

-3
推荐指数
1
解决办法
63
查看次数

如何在没有LWP :: UserAgent或HTTP :: Request的情况下在Perl中发送HTTPS请求?

我需要在不使用LWP :: UserAgent或HTTP :: request的情况下发送HTTPS请求吗?这样做的另一种方法是什么?这是我需要发送的请求:

POST https://payflowpro.paypal.com/
Connection: close
Host: payflowpro.paypal.com
Content-Length: 181
Content-Type: text/namevalue
X-VPS-CLIENT-TIMEOUT: 30
X-VPS-REQUEST-ID: 1249403513SNOID
X-VPS-VIT-INTEGRATION-PRODUCT: Product
X-VPS-VIT-INTEGRATION-VERSION: 4.0
X-VPS-VIT-OS-NAME: linux
X-VPS-VIT-OS-VERSION: 2.6.16-gentoo-r13
X-VPS-VIT-RUNTIME-VERSION: 5.008007

EXPDATE[4]=1011&AMT[6]=100.01&ACCT[16]=4111111111111111&TENDER[1]=C&TAXAMT[4]=0.00&PARTNER[8]=******&PWD[9]=******&VENDOR[6]=******&USER[6]=******&TRXTYPE[1]=S&VERBOSITY=MEDIUM
Run Code Online (Sandbox Code Playgroud)

sockets perl https request

-4
推荐指数
2
解决办法
3276
查看次数