httpyac icon indicating copy to clipboard operation
httpyac copied to clipboard

$random is not defined

Open butonic opened this issue 4 months ago • 1 comments

Hey! thanks for httpYac, awesome tool to replace postman with files I can use in CI as well as the IDE.

I can happily run this request in VSCode:

{{
  const filename = new Buffer($random.alphabetic(50)+'.test', 'utf-8').toString('base64');
}}
// @title initiate first upload
// @name upload1
POST {{baseUrl}}/remote.php/webdav
Tus-Resumable: 1.0.0
Upload-Length: 10
Upload-Metadata: filename {{filename}}, mtime 1712677748, filetype application/zip,
Content-Length: 0
Authorization: Basic {{username}}:{{password}}

?? status == 201 Created

{{
  uploadlocation1 = response.headers.location;
}}

###
// @title finish first upload
// @description This request should fail because another upload has created the same file.
// @name patch1
// @ref upload1
PATCH {{uploadlocation1}}
Tus-Resumable: 1.0.0
Content-Length: 10
Upload-Offset: 0
Content-Type: application/offset+octet-stream

1234567890

?? status == 204 No Content

Love it!

now to make this work with Intellij I understand that it uses different fencing:


< {%
  const filename = new Buffer($random.alphabetic(50)+'.test', 'utf-8').toString('base64');
%}
// @title initiate first upload
// @name upload1
POST {{baseUrl}}/remote.php/webdav
Tus-Resumable: 1.0.0
Upload-Length: 10
Upload-Metadata: filename {{filename}}, mtime 1712677748, filetype application/zip,
Content-Length: 0
Authorization: Basic {{username}}:{{password}}

?? status == 201 Created

> {%
  uploadlocation1 = response.headers.location;
%}

###
// @title finish first upload
// @description This request should fail because another upload has created the same file.
// @name patch1
// @ref upload1
PATCH {{uploadlocation1}}
Tus-Resumable: 1.0.0
Content-Length: 10
Upload-Offset: 0
Content-Type: application/offset+octet-stream

1234567890

?? status == 204 No Content

.. and maybe use request.variables.set

However, I already get a $random is not defined error. Reading the docs I assumed this would work, wouldn't it?

butonic avatar Oct 01 '24 16:10 butonic