Click here to Skip to main content
15,913,587 members
Home / Discussions / C#
   

C#

 
GeneralRe: recording problem Pin
ZurdoDev17-Mar-20 2:59
professionalZurdoDev17-Mar-20 2:59 
GeneralRe: recording problem Pin
Luc Pattyn17-Mar-20 12:08
sitebuilderLuc Pattyn17-Mar-20 12:08 
GeneralRe: recording problem Pin
ago248617-Mar-20 22:04
ago248617-Mar-20 22:04 
GeneralRe: recording problem Pin
Luc Pattyn17-Mar-20 22:18
sitebuilderLuc Pattyn17-Mar-20 22:18 
GeneralRe: recording problem Pin
ago248617-Mar-20 23:20
ago248617-Mar-20 23:20 
AnswerRe: problem to retrieve an info in a sql request / problème pour recéper une info dans une requête sql Pin
Richard Deeming16-Mar-20 9:28
mveRichard Deeming16-Mar-20 9:28 
Generalproblem registering in the access database Pin
ago248617-Mar-20 0:58
ago248617-Mar-20 0:58 
GeneralRe: problem registering in the access database Pin
Richard Deeming17-Mar-20 1:01
mveRichard Deeming17-Mar-20 1:01 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 1:08
ago248617-Mar-20 1:08 
GeneralRe: problem registering in the access database Pin
Richard Deeming17-Mar-20 1:10
mveRichard Deeming17-Mar-20 1:10 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 1:17
ago248617-Mar-20 1:17 
GeneralRe: problem registering in the access database Pin
Richard Deeming17-Mar-20 1:35
mveRichard Deeming17-Mar-20 1:35 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 2:00
ago248617-Mar-20 2:00 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 1:18
ago248617-Mar-20 1:18 
GeneralRe: problem registering in the access database Pin
Richard Deeming17-Mar-20 2:57
mveRichard Deeming17-Mar-20 2:57 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 3:14
ago248617-Mar-20 3:14 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 1:10
ago248617-Mar-20 1:10 
GeneralRe: problem registering in the access database Pin
Richard MacCutchan17-Mar-20 2:18
mveRichard MacCutchan17-Mar-20 2:18 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 2:26
ago248617-Mar-20 2:26 
GeneralRe: problem registering in the access database Pin
Richard MacCutchan17-Mar-20 2:36
mveRichard MacCutchan17-Mar-20 2:36 
QuestionJava Api Callbacks crashes on dotnet framework version 4.5 and above Pin
isaketranjan16-Mar-20 0:06
isaketranjan16-Mar-20 0:06 
AnswerRe: Java Api Callbacks crashes on dotnet framework version 4.5 and above Pin
Gerry Schmitz16-Mar-20 5:05
mveGerry Schmitz16-Mar-20 5:05 
QuestionC# and ODATA CRUD communication with D365BC web service Pin
clemenslinders12-Mar-20 0:13
clemenslinders12-Mar-20 0:13 
SuggestionRe: C# and ODATA CRUD communication with D365BC web service Pin
Richard Deeming12-Mar-20 1:12
mveRichard Deeming12-Mar-20 1:12 
Rather than building the request body by hand, you should use a JSON serializer to create it.

Add a NuGet package reference to JSON.NET[^], add a using directive for the Newtonsoft.Json namespace, and change your code to:
C#
var body = new
{
    No = tbNo.Text,
    First_name = tbFirstName.Text,
    Last_Name = tbLastName.Text,
    FunctionName = tbFunctionName.Text,
};

string json = JsonConvert.SerializeObject(body);
byte[] data = Encoding.UTF8.GetBytes(json);
NB: You'll want to use the UTF8 encoding rather than ASCII, since that's what you've declared in your content-type header.

I'd also be inclined to use the HttpClient class[^] rather than the low-level HttpWebRequest class:
Call a Web API From a .NET Client (C#) - ASP.NET 4.x | Microsoft Docs[^]



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: C# and ODATA CRUD communication with D365BC web service Pin
clemenslinders12-Mar-20 3:48
clemenslinders12-Mar-20 3:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.