x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

UE crashes after Json request.

Hello

I have a problem: when I'm trying to execute JSON request, UE4 editor crashes with this errors in log file:

[2016.07.01-11.44.16:845][166]LogWindows:Error: === Critical error: === Assertion failed: IsValid() [File:D:\EGL\Epic Games\4.11\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h] [Line: 739] [2016.07.01-11.44.16:893][166]LogExit: Executing StaticShutdownAfterError

Here's the sources of executed methods:

 void ALabyrinthCharacter::SendMessageToServer() {
 
 
     TSharedPtr<FJsonObject> JsonObject;
     JsonObject->SetStringField(TEXT("data"), *FString::Printf(TEXT("%s"), "Test data"));
     FString OutputString;
     TSharedRef<TJsonWriter<TCHAR>> JsonWriter = TJsonWriterFactory<>::Create(&OutputString);
     FJsonSerializer::Serialize(JsonObject.ToSharedRef(), JsonWriter);
 
     TSharedRef<IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest();
     HttpRequest->SetVerb("POST");
     HttpRequest->SetHeader("Content-Type", "application/json");
     HttpRequest->SetURL(*FString::Printf(TEXT("%s"), "http://localhost:8080/unreal/persist"));
     HttpRequest->SetContentAsString(OutputString);
     HttpRequest->OnProcessRequestComplete().BindUObject(this, &ALabyrinthCharacter::OnResponseReceived);
     HttpRequest->ProcessRequest();
 
 }
 
 /*Assigned function on successfull http call*/
 void ALabyrinthCharacter::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
 {
 
     if (bWasSuccessful && Response->GetContentType() == "application/json")
     {
         //Create a pointer to hold the json serialized data
         TSharedPtr<FJsonObject> JsonObject;
 
         //Create a reader pointer to read the json data
         TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
 
         //Deserialize the json data given Reader and the actual object to deserialize
         if (FJsonSerializer::Deserialize(Reader, JsonObject))
         {
             FString result = JsonObject->GetStringField("result");
         }
     }
     else
     {
         // Handle error here
     }
 
     
 }

How can I solve it?

Product Version: UE 4.11
Tags:
more ▼

asked Jul 01 '16 at 01:49 PM in C++ Programming

avatar image

Kelheor
76 6 10 16

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

It seems that I found an error.

Instead TSharedPtr JsonObject;
I should write TSharedPtr JsonObject = MakeShareable(new FJsonObject);

Now I can send JSON request, however server isn't receiving it. But this is another story...

more ▼

answered Jul 01 '16 at 02:49 PM

avatar image

Kelheor
76 6 10 16

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hello,
I have the same problem.
The page is called on the server, but nothing in the POST.
Did you find the reason ?

D.

more ▼

answered Sep 16 '16 at 02:28 PM

avatar image

domzorg
714 49 56 128

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question