Good Morning,
I'm using Swift Mailer for applications, but I found that it returns an error code.
ReflectionException
Class Swift_Mime_ContentEncoder_QpContentEncoderProxy does not exist
this is the link: http://demonagency.com/legno/web/site/about
this is a portion code
Yii::$app->mailer->compose()
->setFrom('info#jd.com')
->setTo('prove#jd.com')
->setSubject('Prova jd')
->setTextBody('Testo Prova')
->setHtmlBody('<b>HTML content</b>')
->send();
>
Any idea?
Related
I am a beginner at web development and I am trying to use Postman to send a POST request to one of my application's APIs.
I am using the Next.JS framework to build my website.
Here is my API:
import type { NextApiRequest, NextApiResponse } from "next"
export default async (
req: NextApiRequest,
res: NextApiResponse,
) => {
const userData = JSON.parse(req.body)
res.status(200).json(userData)
}
I simplified my API until I caught the error, and I believe that it is related to the JSON.parse(req.body) line.
This is a print of the data that I used to test the API on Postman
I get the following error:
SyntaxError: Unexpected number in JSON at position 1
at JSON.parse (\u003canonymous\u003e)
at __WEBPACK_DEFAULT_EXPORT__ (webpack-internal:///(api)/./pages/api/login.ts:9:27)
Previously, I used this API to authenticate users, and everything worked fine, except when I tried to insert data into the body of a Postman POST request.
Can someone help me? I have no idea what to do.
If you want to deserialize the body from a POST request, you also have to send a request where the body contains any data because otherwise, req.body will be null and that is not valid json.
Spring REST API is responding with following response:
On successful execution : It returns me a response of Text type.
On unsuccessful execution : It returns me JSON error object.
Front-End Service Class :
private detailsURL = 'http://localhost:8080/register';
constructor(private http:HttpClient){}
register(regisDetails): Observable<any>{
return this.http.post(this.detailsURL,regisDetails);
}
Front-End Component Class:
registerUser(){
this.service.register(this.regisForm.value).subscribe(
success => this.successMessage = success,
error => this.errorMessage = error.error.errorMessage
);
}
In case of error I'm getting the error message I'm supposed to get. But in case of success I'm not getting the successMessage.
Just wanted to know if there's any way to fetch the Text type response on front end. Or else I'll have to change my backend to send response of JSON Type for successful execution as well.
Please help me understand this thing.
You have to set the status for your response. In the controller part you have to mention consumes="application/json" in api request.
You should be doing your changes at the backend and provide the response in Json format response for both the success and backend. That would be the ideal solution.
It is really a bad design to provide a different response than what is expected. You could check the value of the header in request "accept:application/json" and provide response as was expected by the front end
Front End Fix :
However, in the front end you could always use
JSON.parse(success) to convert the text to Json object and use it further as required.
I am working with a web app. I've frontend in Angular 4 and backend in Django Rest.
When I want receive information since the API it works wonderfull, but when I try to send datas to save in the data base with the API I have this error: "Unsupported media type \"text/plain\" in request.".
I think that my API configuration is rigth, because I've researching and I find the same error and the trouble is in Angular. I've tryed all I've found, but nothing work to me.
This is my Angular code for this:
enviar() {
var body = '"schema_name":"pruebanm","fecha_alta":"2018-02-01","nombre":"cliente","ubicacion":"prueba","telefono":"1234567","correo":"cliente#prueba.com","activo":true';
this.http.post("http://tenant1.intrainingls.com:8000/viewSets/cliente/", JSON.stringify(body)).subscribe((data) => {});
}
I hope somebody can help me to find the solution. (data in body is to try)
PD. And if you need more information, please, tell me.
As specified in the error "you are using a wrong media type".
Change it to application/json:
The body of your HTTP request must be an object:
var body = { "schema_name":"pruebanm","fecha_alta":"2018-02-01","nombre":"cliente","ubicacion":"prueba","telefono":"1234567","correo":"cliente#prueba.com","activo":true };
And there is no need to stringify it:
enviar() {
var body = '"schema_name":"pruebanm","fecha_alta":"2018-02-01","nombre":"cliente","ubicacion":"prueba","telefono":"1234567","correo":"cliente#prueba.com","activo":true';
this.http.post("http://tenant1.intrainingls.com:8000/viewSets/cliente/", body).subscribe((data) => {});
}
https://angular.io/guide/http#making-a-post-request
I have to send by post to a URL string of JSON text, I use a TidHTTP component for sending by post as shown in the code below, but when I hit the submit button I skip this error, I've been searching google to another people that this happens but none of the solutions have helped me in this case.
var
postData:String;
url:String;
contestacion:String;
datosPOst:TStringList;
lista:TMemoryStream;
begin
datosPOst:=TStringList.Create;
datosPOst.Text:='{'+#10+'"ticketCode": "asdasd",'+#10+
'"CIF": "***",'+#10+
'"storeCode": "***",'+#10+
'"saleTimeStamp": "\/Date(123456000000)\/",'+#10+
'"email": "prueba#***",'+#10+
'"userCP": "30280",'+#10+
'"products": ['+#10+
'{'+#10+
'"Amount": 1,'+#10+
'"Description": "PRUEBA ticket",'+#10+
'"Name": "Prueba ticket 2",'+#10+
'"Price": 25.25,'+#10+
'"ProductCode": "50",'+#10+
'"Tax": 21,'+#10+
'"UnitPrice": 250.00'+#10+
'}'+#10+
'],'+#10+
'"user": "****",'+#10+
'"password": "****"'+#10+
'}';
lista:=TMemoryStream.Create;
datosPOst.SaveToStream(lista);
contestacion:=conexion.Post('http://****.com/Ticket.svc/rest/InsertTicket',lista);
Also if there is any way to form a json from delphi also would appreciate
Thanks
Now I have the solution:
conexion.Request.ContentType:='application/json';
And is working
Error 400 is a reply you get when there are errors in your JSON.
I would advise using another component to send your POST request, a component that does give you the body text back, because that's what you need.
Synapse has an alternative to idHTTP.
In Drupal 7.14, when i Index my Whole Site, Solr is showing following error:
AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows.
Path: /batch?id=1938&op=do StatusText: Service unavailable (with message)
ResponseText: EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7539 of /project/path/includes/common.inc).
So when i look into the lines in /includes/common.inc (around lines: 7537):
// Explicitly fail for malformed entities missing the bundle property.
if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
throw new EntityMalformedException(t('Missing bundle property on entity of type #entity_type.', array('#entity_type' => $entity_type)));
}
What is that chunk of code (in common.inc) is doing actually please?
How can i overcome that error?
Please, try this module https://drupal.org/project/taxonomy_orphanage it will delete all empty bundles.