0

I am running scripts which compares API response with values from CSV file,

Undelying CUSIP Number 1 | AssertionError: expected '24936205' to deeply equal '024936205'

I receive above error as i am not able to store leading 0 in csv. Any suggestions?

Note - I tried changing the format of cell to text and added 0 in front but when i close leading zero disappears.

Coder
  • 3
  • 2

2 Answers2

0

Open the CSV file with MS Excel. Use the excel formula to format the cell. Say I want five-digit number with leading zero for a four-digit number.

You can use like this in excel.

 =TEXT(A2,”00000″)

After changing the values, copy the same cell and paste as values. This should work.

rna
  • 426
  • 3
  • 6
  • I used the formula and it does add leading zero but when i run script it fails with same error. – Coder Jan 04 '21 at 19:02
  • Did you copy and paste the numbers as text/values after conversion? – rna Jan 05 '21 at 17:25
  • i tried that and it shows me as text but after closing and running through postman it still not treats as text. – Coder Jan 07 '21 at 22:31
  • I found that it was a postman issue. Fix will be changing the value in CSV as a string. Eg. "024936205". Reference [Link](https://github.com/postmanlabs/postman-app-support/issues/2734) – rna Jan 08 '21 at 02:34
0

I managed to get my requests to work, by adding a couple of lines to the pre-request script (My variable is always the same length, hence the if):

var policyno = data['PolicyNo'].toString()
if(policyno.length < 12){
   policyno = '0'+ policyno
   pm.variables.set("PolicyNo",policyno)
}

this works with CSV data.

Kate Alsh
  • 1
  • 3