System.FormatException: The format of value '' is invalid.
See original GitHub issueHello there!
I’m trying to make a request like this
#r "nuget: FsHttp"
open FsHttp
http {
POST "https://api.jspm.io/generate"
body
json ("""{
"install": [ "lodash" ],
"env": [ "browser", "module" ],
"graph":true,
"provider": "jspm"}""")
}
|> Request.send
|> Response.toText
|> printfn "%s"
the expected JSON content is the following
{
"staticDeps": [
"https://ga.jspm.io/npm:lodash@4.17.21/lodash.js"
],
"dynamicDeps": [],
"map": {
"imports": {
"lodash": "https://ga.jspm.io/npm:lodash@4.17.21/lodash.js"
}
},
"graph": {
"https://ga.jspm.io/npm:lodash@4.17.21/": {
"lodash.js": {}
}
}
}
but I get the following instead
PS C:\Users\scyth\repos\scripts> dotnet fsi script2.fsx
System.FormatException: The format of value '' is invalid.
at System.Net.Http.Headers.HttpHeaderParser.ParseValue(String value, Object storeValue, Int32& index)
at System.Net.Http.Headers.HttpHeaders.ParseAndAddValue(HeaderDescriptor descriptor, HeaderStoreItemInfo info, String value)
at System.Net.Http.Headers.HttpHeaders.Add(HeaderDescriptor descriptor, String value)
at FsHttp.Request.toAsync@152-4.Invoke(CancellationToken ctok)
at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, b result1, FSharpFunc`2 userCode) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 528
at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
--- End of stack trace from previous location ---
at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 454
at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1140
at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1511
at <StartupCode$FSI_0002>.$FSI_0002.main@() in C:\Users\scyth\repos\scripts\script2.fsx:line 6
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error
When I use nightingale I get this log, not sure if it helps at all
Method: POST, RequestUri: 'https://api.jspm.io/generate', Version: 2.0, Content: System.Net.Http.StringContent, Headers:
{
Content-Type: application/json; charset=utf-8
}
StatusCode: 200, ReasonPhrase: '', Version: 2.0, Content: System.Net.Http.StreamContent, Headers:
{
Server: Google
Server: Frontend
Date: Fri, 30 Sep 2022 00:16:50 GMT
Access-Control-Allow-Origin: *
Content-Type: application/json
}
Let me know if you need further information
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Adding HttpClient headers generates a FormatException ...
System.FormatException : The format of value key=XXX' is invalid. The solution is to remove the equals sign. Digging into reflector ...
Read more >Adding HttpClient headers generates a FormatException ...
System.FormatException : The format of value key=XXX' is invalid. The solution is to remove the equals sign. Digging into reflector ...
Read more >FormatException Class (System)
The exception that is thrown when the format of an argument is invalid, or when a composite format string is not well formed....
Read more >[Solved] Httpclient authorization issue
Why HttpClient rejects that exact value with a FormatException, is because it is an invalid Authorization value: valid Authorization values ...
Read more >The format of value xxx is invalid · Issue #5046
I get the following exception when I run the code (I use Mac): The format of value ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I added a PR that should fix this issue.
Yep, me too. 😄 This fix helped a lot!