function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HennHenn 

Pushing source to scratch org fails: Illegal Request - You have sent us an Illegal URL or an improperly formatted request.

Have some code in VS Code, received from a scratch org with enabled Community(Digital Experiences). Want this to push to a new scratch org. "Push Source to Default Scratch Org" always fails with exit code 1
SfdxError: 
<html> <body>
<table cellspacing=10><tr><td><span style="font-weight: bold; font-size: 12pt;">Illegal Request</span></td></tr>
    <tr<td>You have sent us an Illegal URL or an improperly formatted request.</td></tr>
    <tr><td></td></tr></table>
<!-- Body events -->
<script type="text/javascript">function bodyOnLoad(){if(window.PreferenceBits){window.PreferenceBits.prototype.csrfToken="null";};}function bodyOnBeforeUnload(){}function bodyOnFocus(){}function bodyOnUnload(){}</script></body></html>

Tried a lot, but still have no clue: minimal project-scratch-dev.json, CLI latest version (7.92) and also an older; Has someone an idea where to look for error reason? Any help would be greatly appreciated.

Best Answer chosen by Henn
pk1772pk1772
This is DX bug probably introduced in the latest-rc or version plugin version 50.4.0. You can track it here - 
https://github.com/forcedotcom/cli/issues/860

As one the contributors commented, switching from REST to SOAP will help get past the issue - 
sfdx config:set restDeploy=false

Else, you can also downgrade the plugin version to 50.13.3 (Works for me) - 
sfdx plugins:install salesforcedx@50.13.3

All Answers

AnudeepAnudeep (Salesforce Developers) 
Hi Henn,

What is your sourceApiVersion? Can you try changing it to the latest version?

\sfdx-project.json => change "sourceApiVersion" to latest version

Also, can you please try executing the following command (below is an example) and also try pushing the code to different enviroment
 
sfdx force:source:push --targetusername test-b4agup43oxmu@example.com

https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_push_md_to_scratch_org.htm

Let me know what you see
David Tissen 7David Tissen 7
Seems to be a random issue, just make some changes in your code, try again.
HennHenn
Thank you for your replies.
"sourceApiVersion" is "51.0"
I created several scratch orgs, code pushing did not work for any.
I just tried sfdx force:source:push --targetusername test-u5kme8owvned@example.com --loglevel=TRACE, which only givesme same HTML back
*** Deploying with REST ***
ERROR running force:source:push:  
<html>
<body>...Illegal Request</span></td>...
pk1772pk1772
This is DX bug probably introduced in the latest-rc or version plugin version 50.4.0. You can track it here - 
https://github.com/forcedotcom/cli/issues/860

As one the contributors commented, switching from REST to SOAP will help get past the issue - 
sfdx config:set restDeploy=false

Else, you can also downgrade the plugin version to 50.13.3 (Works for me) - 
sfdx plugins:install salesforcedx@50.13.3
This was selected as the best answer
SScholtzSScholtz
Thanks pk1772 for the info.  I ran into this "illegal request" error yesterday evening while trying to deploy to a sandbox.  Found out I was a few versions behind on the CLI, so I updated and the error got worse, going to an "Internal Server Error" next.

I tried the SOAP approach (restDeploy=false) and that worked for me, at least for now.  Will need to find time to dig into the github bug thread to see the origins of the issue.
HennHenn
pk1772 -thank you very much for help. Switch sfdx config:set restDeploy=false worked for me.
I had looked for a clue there in github, but obviously not thoroughly enough. I'm happy now!
Piotr AntoszPiotr Antosz
@pk1772 - thank you! It worked for me. Cheers!
Yuki Cheng 5Yuki Cheng 5
thanks, works for me : sfdx config:set restDeploy=false
wu fangwu fang
@pk1772 - thank you! It worked for me. Cheers!
 
Joe McVicker 22Joe McVicker 22
@pk1772 - set restDeploy=false solved it for me too.  Any reason to turn it back to restDeploy=true when fixed?
Sudeep JoshiSudeep Joshi
@pk1772 - Thanks! It solved my issue!