• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
2

Adding Content-Type to a Net.HTTP.request()

New Here ,
May 22, 2024 May 22, 2024

Copy link to clipboard

Copied

I have a simple function that sends some JSON to my API.

 

However, when the server receives it, it says the the Content Type is invalid as it is '' (empty).

 

var saveAssessment = app.trustedFunction(function() {
    const params = {

       cVerb: "POST",
       cURL: "http://localhost:8089/api/step-by-step-assessment",
       oBody: assessmentJsonString,
       aHeaders: {
          "Content-Type": "application/json",

       },
       oHandler: {
          response: function(msg, uri, error) {
             if (error != undefined) {
                app.alert("Error ocurred: " + JSON.stringify(error));
             } else app.alert("Success!");
          },

       }

    };

 

    Net.HTTP.request(params);
});

TOPICS
JavaScript , Modern Acrobat , PDF

Views

179

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
New Here ,
May 23, 2024 May 23, 2024

Copy link to clipboard

Copied

LATEST

The assessmentJsonString is not null, I just excluded it from the post.

 

I did actually find the solution, which was changing my endpoint to accept 'application/octet-stream'. Because, changing the Content-Type did not actually change it's type.

View solution in original post

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2024 May 23, 2024

Copy link to clipboard

Copied

May be that assessmentJsonString is empty.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 23, 2024 May 23, 2024

Copy link to clipboard

Copied

LATEST

The assessmentJsonString is not null, I just excluded it from the post.

 

I did actually find the solution, which was changing my endpoint to accept 'application/octet-stream'. Because, changing the Content-Type did not actually change it's type.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines