arabic messages with postman received as '???????' - json

I need to send an Arabic message with postman. I recieve the text as ??????? instead of arabic characters.
here's the body of my request in postman :
{
"authentication": {
"username": "myusernam",
"password": "mypassword"
},
"messages": {
"sender": "Mysender",
"text": "رأيكم يهمنا. المرجو تنقيط جودة استفدتم منها عبر الرابط التالي: ht
"recipients": [
{
"gsm": "21260000000"
}
]
}
}
and here are the headers that I have included:
Content-Type : application/json; charset = utf-8
Accept : application/json; charset = utf-8

use this
value = System.Uri.UnescapeDataString(value);

Related

Getting an error "Can not deserialize instance of java.lang.String out of START_OBJECT " even though the Json code is from Docs

I took this syntax for the payload from the formal docs of jira, yet i am still getting an error. I am using either python or curl both give the same error. I supppose this is a Json related issue , could you find what is wrong with the jason/payload and how do i go about fixing it?
import requests
import json
url = "https://jira.company.io/rest/api/latest/issue/ISS-37424/transitions"
payload = json.dumps({
"update": {
"comment": [
{
"add": {
"body": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Bug has been fixed",
"type": "text"
}
]
}
]
}
}
}
]
},
"transition": {
"id": "2"
}
})
headers = {
'Authorization': 'Basic YmVzQ=LKKJYTFTgfg','
Accept': 'application/json',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

Ajax post request to google NLP

Im trying to do a post request to GCP Natural Language for sentiment analysis.
When I try the data format on the code explorer on google it works fine but when I run it on a html page I get an error that reads
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"document[type]\": Cannot bind query parameter. Field 'document[type]' could not be found in request message.\nInvalid JSON payload received. Unknown name \"document[content]\": Cannot bind query parameter. Field 'document[content]' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"document[type]\": Cannot bind query parameter. Field 'document[type]' could not be found in request message."
},
{
"description": "Invalid JSON payload received. Unknown name \"document[content]\": Cannot bind query parameter. Field 'document[content]' could not be found in request message."
}
]
}
]
}
}
My code is:
<!DOCTYPE html>
<html>
<body>
<h1> Testing sentiment Analysis </h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var APIKEY = "AN API KEY";
$.ajax({
type : "POST",
url : "https://language.googleapis.com/v1/documents:analyzeSentiment?key="+APIKEY,
data : {
"document": {
"type": "PLAIN_TEXT",
"content": "Hello I am great"
},
"encodingType": "UTF8",
},
success: function(res) {
console.log(res);
alert(res['message']);
},
error: function(res) {
console.log(res['message']);
alert(res);
},
});
</script>
</body>
</html>
UPDATE:
A colleague has pointed me to the MISTAKE I was making. We have to use JSON.stringify() in order to send the request. The code should be like this:
$.ajax({
type : "POST",
url : "https://language.googleapis.com/v1/documents:analyzeEntitySentiment?key=YOUR-API-KEY",
contentType : "application/json; charset=utf-8",
data :
JSON.stringify({
"document": {
"type": "PLAIN_TEXT",
"language": "en",
"content": "Hola Victor"
},
"encodingType": "UTF8"}),
success : function(_result){
if (_result) {
alert('SUCCESS');
} else {
alert('ERROR');
}
},
error : function(_result){
}
});
I have tested it and it works.

Issue in json request

I am sending below json request but getting error while hitting in application. below is the request format. I want to send json request which will return a xml response.
{
"Request": {
"Header": {
"Version": "1.0",
"Command": "ActiveTest",
"cc": {
"cctype": "1",
"id": "Test_id",
"Password": "********"
},
"KeyOwner": "1",
"Timestamp": "20151211121212"
},
"Body": {
"user": {
"Init": {
"idtype":"1",
"id": "88384648929",
"pass":"1234244"
},
"ActiveTest": {
}
}
}
}
}
Error:
Unexpected character '"' (code 34) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]|Param={void}
Where do you send your request to?
For me the response looks like the server expects xml and the xml-parser is complaining, that the opening < character is missing.

Solr update with Rest API Json data

I'm using solr 6.5.1. I have json data in Rest url;
For example:
POST : http://localhost:8484/api/cloud/list-users
is_user: xxx
is_key : pqxqxaweqweqx14123
I can able to fetch data via postman rest client. Is there anyway to post data to solr collection via above rest post url? Please tell me how do i implement this feature in solr.
Try this:
POST /api/cloud/list-users/update/json/docs?commit=true HTTP/1.1
Host: localhost:8484
Content-Type: application/json
{
"is_user": "xxx",
"is_key": "pqxqxaweqweqx14123"
}
And if you want to import it into Postman, here's a json (save it to a .json and then import it as a collection into Postman)
{
"variables": [],
"info": {
"name": "Solr Post New Document",
"_postman_id": "291f6b0e-6aad-7778-c29d-f194ce45c5de",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "Solr Post New Document",
"request": {
"url": "http://localhost:8983/solr/test/update/json/docs?commit=true",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n\"is_user\": \"xxx\",\n\"is_key\": \"pqxqxaweqweqx14123\"\n}\n"
},
"description": ""
},
"response": []
}
]}
For more details, see the solr documentation:
https://cwiki.apache.org/confluence/display/solr/Uploading+Data+with+Index+Handlers#UploadingDatawithIndexHandlers-JSONFormattedIndexUpdates

Docusign Multipart Form Request to Upload Multiple Documents

Can someone please help me with the Json Request to upload multiple documents in a envelope. I have pasted the request below.
The error that I get is
API call failed, status returned was: 400
Error description:
{ "errorCode": "NO_DOCUMENT_RECEIVED", "message": "The document element did not contain the encoded document, or there is a problem with the encoding. Bytes for document corresponding to documentId 1 not found in request. 'documentId=' possibly missing from Content-Disposition header."}
--BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"emailSubject" : "This is email subject",
"emailBlurb" : "This is email body",
"recipients" : {
"signers" : [ {
"routingOrder" : "1",
"name" : "name",
"email" : "valid email address",
"recipientId" : "1",
"tabs" : {
"signHereTabs" : [ {
"anchorTab" : {
"anchorString" : "SignHere",
"anchorXOffset" : "1",
"anchorYOffset" : "1",
"anchorIgnoreIfNotPresent" : "true",
"anchorUnits" : "inches"
}
} ]
}
} ]
},
"documents" : [ {
"name" : "document.pdf",
"documentId" : "1"
}, {
"name" : "document2.pdf",
"documentId" : "2"
} ],
"status" : "sent"
}
--BOUNDARY
Content-Disposition: form-data
Content-Type: multipart/mixed; boundary=BBB
--BBB
Content-Type: application/pdf
Content-Disposition: file; filename="document.pdf"; documentid="1"
[B#47df4d31
--BBB
Content-Type: application/pdf
Content-Disposition: file; filename="document2.pdf"; documentid="2"
[B#1544f0d4
--BBB--
--BOUNDARY--