cURL to PowerShell
curl command paste kijiye aur Invoke-RestMethod wala PowerShell script paiye, aise quoting ke saath jo aapka token na kha jaye.
cURL to PowerShell aapke browser mein convert karta hai. Token ya credentials wale commands device se bahar nahin jate.
cURL to C# kholiye
cURL to PowerShell ke baare mein
curl command ko PowerShell mein paste karna shayad hi chalta hai, aur sirf flags ki wajah se nahin. PowerShell double quotes ke andar variables interpolate karta hai, isliye dollar sign wala token chupchap khaali string ban jata hai aur request 401 lautati hai bina koi ishara diye. Ye converter single-quoted literals banata hai, jinhe PowerShell raw text maanta hai. Headers hashtable bante hain aur JSON body ConvertTo-Json se guzarti hai taaki bhejne se pehle edit ho sake.
Features
- Invoke-RestMethod, parameters padhne layak lines mein
- Headers PowerShell hashtable ke roop mein
- JSON body hashtable jo ConvertTo-Json se guzarti hai
- Single quotes taaki token ka $ kabhi interpolate na ho
- Basic auth Base64 Authorization header ke roop mein
- Conversion aapke browser mein hota hai
cURL to PowerShell kaise use karein
- Documentation se curl command copy kijiye
- Baayen panel mein paste kijiye
- Daayen taraf bana PowerShell dekhiye
- Copy kijiye ya .ps1 file download kijiye
Example
Input
curl https://api.example.com/users -H "X-Api-Key: abc123"
Output
$headers = @{
'X-Api-Key' = 'abc123'
}
$response = Invoke-RestMethod `
-Uri 'https://api.example.com/users' `
-Method GET `
-Headers $headers
Single quotes value ko literal rakhte hain, characters chahe jo hon.
Common errors aur troubleshooting
- Token sahi hone par bhi request 401 deti hai. — Double-quoted string dollar sign ke baad sab interpolate kar deti hai aur token ka hissa gayab ho jata hai. Single quotes rehne dijiye ya dollar ko backtick se escape kijiye.
- JSON body server par bigdi hui pahunchti hai. — ConvertTo-Json ka -Depth dekhiye. Default 2 hai jo nested objects ko chupchap flatten kar deta hai — bana hua code isliye 10 set karta hai.
- Non-ASCII characters kharaab aa rahe hain. — Windows PowerShell 5.1 body par UTF-8 se alag encoding leta hai. PowerShell 7 par jaiye, ya JSON ko UTF-8 bytes mein badal kar bhejiye.
Aksar pooche jaane wale sawaal
- Kya PowerShell mein curl aur Invoke-WebRequest ek hi hain?
- Windows PowerShell 5.1 mein curl Invoke-WebRequest ka alias hai, isliye asli curl command paste karne par ajeeb parameter errors aate hain. PowerShell 7 ne alias hata diya.
- Invoke-RestMethod lein ya Invoke-WebRequest?
- API ke liye Invoke-RestMethod, kyunki wo JSON response ko objects mein badal deta hai. Invoke-WebRequest raw response status code aur headers ke saath deta hai, jab ye vivaran zaroori ho.
- PowerShell mein basic authentication kaise bhejein?
- username:password ko Base64 mein encode karke Authorization header ke roop mein bhejiye. -Credential parameter hai par wo credentials sirf challenge ke baad bhejta hai, jo kai APIs kabhi nahin bhejtin.
- Parameters backtick se kyun tode gaye hain?
- Backtick PowerShell ka line continuation character hai, jisse lambi call kai lines mein padhne layak rehti hai. Wo line ka aakhri character hona chahiye, uske baad space nahin.
Related tools
- cURL to Ruby — Convert a curl command to Ruby Net::HTTP code.
- curl to Python — Ek curl command ko Python requests code mein convert karein.
- cURL se C# — curl command ko HttpClient wale C# code me badlein.
- curl to Node.js — Ek curl command ko Node.js axios code mein convert karein.
- curl to Go — Ek curl command ko Go net/http code mein convert karein.
- cURL se Fetch — Ek curl command ko JavaScript fetch() call mein convert karein.
Saare ArrayKit tools