Skip to content

JSON beautify action in request body does not work when there are Postman variables #4313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yishayn opened this issue Mar 9, 2018 · 9 comments · Fixed by #8601
Closed

Comments

@yishayn
Copy link

yishayn commented Mar 9, 2018

Postman for Windows
Version 6.0.9
win32 10.0.16299 / x64

Issue Report:

After upgrading form latest version 5 into postman 6.0.9
I noticed a change in the "CTRL+B", as followed:

  • when pasting a JSON request into postman request window, and using 'CTRL+B' to fix it to be in normal JSON format. In version 6.0.9 , it is doing it , but adding extra spaces each indentation branch.
    See attached PDF to see screenshots to illustrate it.

CTRL+B , Steps To Reproduce.pdf

Note:
In addition , also in older versions ,
if you already have the request in good JSON format,
and you need to insert into it new rows which are not,
at this point, 'CTRL+B' is not doing anything.

In this case, I simply use online JSON Viewer to fix it.

Thanks.

@anuragw
Copy link

anuragw commented Mar 15, 2018

+1

Facing a similar issue. 6.0.9 seems to be using 4 space indentation instead of the previous 2.

@preethammavin
Copy link
Member

Hi,
This issue should be fixed in the latest version of the app, can you update and verify if its fixed?

@yishayn
Copy link
Author

yishayn commented Jul 18, 2018

Hi, sorry for the delay.
I don't see it is fixed.
Can you please clarify what should be the condition for "CTRL+B" feature to work at all ?
Sometimes it works, and sometimes its doing nothing.
example: If I take a Request Body, which is already in JSON format, and remove all SPACES ,
then, Paste it on a new TAB which is set to raw-JASON,
the CTRL+B is doing nothing.

Only sometimes, when I click on it, it is working.
and from what I see, it is still with 4 spaces.
I am using latest version 6.1.4 using same windows 10 x64

Thank you!
And again, sorry for the delay in my response.
Appropriate your hard work!

@prashantagarwal
Copy link

@yishayn Can you share me a sample Json for which it is not working. That will really help in fixing this bug.

@prashantagarwal
Copy link

Closing due to inactivity.

@yishayn
Copy link
Author

yishayn commented Aug 17, 2018

Hi @prashantagarwal @preethammavin
Sorry for my delayed response.

I think I was able to find the problem Root Cause

Problem Description:

  • As you know, if I want to use environment parameter in a request body, I need to use curly braces : {{variable}}
  • The problem root case is if I have in my request body mixed variable of Integer & string.
    i.e.
    If this is a string , it will be with quotation marks as followed: "{{string}}"
    In case the variable representing Integer, it will be set without quotation marks as followed: {{Int}}

To reproduce the problem:

Test-case 1:
Request body set as JSON format with the following:

{
"Test1": "{{Test1}}",
"Test2": "{{Test2}}",
"Test3": "{{Test3}}",
"Test4": "{{Test4}}"
}

If I will use the "CTRL+B" feature ,
it will be Successful
The JSON Indentation will work and will modify it as followed:

{
"Test1": "{{Test1}}",
"Test2": "{{Test2}}",
"Test3": "{{Test3}}",
"Test4": "{{Test4}}"
}


Test Case 2:

The difference is that now the {{Test2}} variable need to be sent as Integer (without quotation marks ).
Request body set as JSON format with the following:

{
"Test1": "{{Test1}}",
"Test2": {{Test2}},
"Test3": "{{Test3}}",
"Test4": "{{Test4}}"
}

If I will use the "CTRL+B" feature ,
Nothing is happening ...
it will remain the same.

I hope now you will be able to reproduce.


Use Case 3:

If we talk about the original issue mention above is about the number of spaces you add in your automatic JSON Indentation feature.

Lets take the same example below.
As you can see, I deleted the space characters. each row start at the beginning of each row.

{
"Test1": "{{Test1}}",
"Test2": "{{Test2}}",
"Test3": "{{Test3}}",
"Test4": "{{Test4}}"
}

If I will use the "CTRL+B" feature ,
The JSON Indentation will fix the JSON Indentation by adding 4 space characters at the beginning of each parameter as followed:

{
"Test1": "{{Test1}}",
"Test2": "{{Test2}}",
"Test3": "{{Test3}}",
"Test4": "{{Test4}}"
}

As I mention,
in older postman version,
the JSON Indentation would have add only 2 space characters , for each Indentation that is needed.

Perhaps you can make it configurable ?
Please see example of the following site:
https://sqlformat.org/

at the bottom right-side ,
it has the option to configure "Indentation" .
i.e. for each Indentation, how many spaces to add.

Thank you.

@abhijitkane abhijitkane reopened this Aug 21, 2018
@prashantagarwal
Copy link

@yishayn Thank you for such detailed explanation. It really helped us in triaging this. I will see to it that we get this fixed soon.

@yishayn
Copy link
Author

yishayn commented Aug 22, 2018

@prashantagarwal ,
Thank you for the feedback !

@kamalaknn kamalaknn changed the title [Postman 6.0.9] "CTRL+B" feature - JSON Indentation - Duplicated Space Char JSON beautify action in request body does not work when there are Postman variables Mar 18, 2020
@pankajk07
Copy link
Member

This is fixed as part of v7.26. Please update your app and try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants