Posts

Showing posts with the label post

Angular HTTPClient POST body not sending

Angular HTTPClient POST body not sending Currently I am trying to POST a name, email and message from an angular frontend to a php script running in the same nginx server which then runs phpmailer to send an email containing the name, email and message. Here is the code so far: import { Component, OnInit } from '@angular/core'; import { Email } from './email'; import {ContactService} from './contact.service'; import {HttpClient, HttpHeaders} from '@angular/common/http'; import {NgForm} from '@angular/forms'; const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' }) }; const email = new Email('', '', ''); @Component({ selector: 'app-contact', templateUrl: './contact.component.html', styleUrls: ['./contact.component.css'], providers: [ContactService] }) export class ContactComponent implements OnInit { email = new Email(...

I got a System error in C# post

Image
I got a System error in C# post It is my first time to ask a question in here (I'm from Asia). Platform:UWP 17632 IDE : Visual Studio 2017 Based on the reqiurement of the project, I need to post some information to a website. I refer the answer about How to make HTTP POST web request Method A. Here is my code: public async void PostDataAsync(string pTemperture, string pHumidity, string pFireStatus, string pLightStatus, string pBodyStatus) { var values = new Dictionary<string, string> { {"count", "1" }, {"temperture_0", pTemperture }, {"Humidity_0", pHumidity }, {"FireStatus_0", pFireStatus }, {"LightStatus_0" ,pLightStatus}, {"BodyDetect_0", pBodyStatus } }; var content = new FormUrlEncodedContent(values); try { var response = await client.PostAsync("...